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CAAC,EAAxC,CAAwC,CAAC,CAAC;QACvF,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,QAAQ,GAAG,EAAE,CAAC;QAClB,CAAC;QAED,MAAM,CAAC,IAAI,iBAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IA7DQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CA8D1B;IAAD,qBAAC;CAAA,AA9DD,CAAoC,mCAAsB,GA8DzD;AA9DY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, TupleType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:tuple'})\nexport class TupleConverter extends ConverterTypeComponent implements TypeConverter<ts.TypeReference, ts.TupleTypeNode> {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TupleTypeNode): boolean {\n return node.kind === ts.SyntaxKind.TupleType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.TypeReference): boolean {\n return !!(type.objectFlags & ts.ObjectFlags.Tuple);\n }\n\n /**\n * Convert the given tuple type node to its type reflection.\n *\n * This is a node based converter, see [[convertTupleType]] for the type equivalent.\n *\n * ```\n * let someValue: [string,number];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The tuple type node that should be converted.\n * @returns The type reflection representing the given tuple type node.\n */\n convertNode(context: Context, node: ts.TupleTypeNode): TupleType {\n let elements: Type[];\n if (node.elementTypes) {\n elements = node.elementTypes.map((n) => this.owner.convertType(context, n));\n } else {\n elements = [];\n }\n\n return new TupleType(elements);\n }\n\n /**\n * Convert the given tuple type to its type reflection.\n *\n * This is a type based converter, see [[convertTupleTypeNode]] for the node equivalent.\n *\n * ```\n * let someValue: [string,number];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The tuple type that should be converted.\n * @returns The type reflection representing the given tuple type.\n */\n convertType(context: Context, type: ts.TypeReference): TupleType {\n let elements: Type[];\n if (type.typeArguments) {\n elements = type.typeArguments.map((t) => this.owner.convertType(context, null, t));\n } else {\n elements = [];\n }\n\n return new TupleType(elements);\n }\n}\n"]}
|