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nB,cAAc,CAsD1B;IAAD,qBAAC;CAAA,AAtDD,CAAoC,mCAAsB,GAsDzD;AAtDY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, ArrayType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:array'})\nexport class ArrayConverter extends ConverterTypeComponent implements TypeConverter<ts.TypeReference, ts.ArrayTypeNode> {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.ArrayTypeNode): boolean {\n return node.kind === ts.SyntaxKind.ArrayType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.TypeReference): boolean {\n // Is there a better way to detect the {\"type\":\"reference\",\"name\":\"Array\",\"typeArguments\":{...}} types that are in fact arrays?\n return !!(type.flags & ts.TypeFlags.Object) && !!type.symbol && type.symbol.name === 'Array' && !type.symbol.parent && !!type.typeArguments && type.typeArguments.length === 1;\n }\n\n /**\n * Convert the given array type node to its type reflection.\n *\n * This is a node based converter with no type equivalent.\n *\n * ```\n * let someValue: number[];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The array type node that should be converted.\n * @returns The type reflection representing the given array type node.\n */\n convertNode(context: Context, node: ts.ArrayTypeNode): Type {\n const result = this.owner.convertType(context, node.elementType);\n\n return new ArrayType(result);\n }\n\n /**\n * Convert the given type reference to its type reflection.\n *\n * This is a type based converter, see [[convertTypeReference]] for the node equivalent.\n *\n * ```\n * class SomeClass { }\n * let someValue: SomeClass;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The type reference that should be converted.\n * @returns The type reflection representing the given type reference.\n */\n convertType(context: Context, type: ts.TypeReference): Type {\n const result = this.owner.convertType(context, null, type.typeArguments[0]);\n\n return new ArrayType(result);\n }\n}\n"]}
|