(type, mapper, aliasSymbol, aliasTypeArguments)
| 63400 | return result; |
| 63401 | } |
| 63402 | function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { |
| 63403 | var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : |
| 63404 | type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : |
| 63405 | type.symbol.declarations[0]; |
| 63406 | var links = getNodeLinks(declaration); |
| 63407 | var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : |
| 63408 | type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; |
| 63409 | var typeParameters = links.outerTypeParameters; |
| 63410 | if (!typeParameters) { |
| 63411 | // The first time an anonymous type is instantiated we compute and store a list of the type |
| 63412 | // parameters that are in scope (and therefore potentially referenced). For type literals that |
| 63413 | // aren't the right hand side of a generic type alias declaration we optimize by reducing the |
| 63414 | // set of type parameters to those that are possibly referenced in the literal. |
| 63415 | var outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true); |
| 63416 | if (isJSConstructor(declaration)) { |
| 63417 | var templateTagParameters = getTypeParametersFromDeclaration(declaration); |
| 63418 | outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); |
| 63419 | } |
| 63420 | typeParameters = outerTypeParameters || ts.emptyArray; |
| 63421 | var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; |
| 63422 | typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? |
| 63423 | ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : |
| 63424 | typeParameters; |
| 63425 | links.outerTypeParameters = typeParameters; |
| 63426 | } |
| 63427 | if (typeParameters.length) { |
| 63428 | // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the |
| 63429 | // mapper to the type parameters to produce the effective list of type arguments, and compute the |
| 63430 | // instantiation cache key from the type IDs of the type arguments. |
| 63431 | var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); |
| 63432 | var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); |
| 63433 | var newAliasSymbol = aliasSymbol || type.aliasSymbol; |
| 63434 | var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); |
| 63435 | var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); |
| 63436 | if (!target.instantiations) { |
| 63437 | target.instantiations = new ts.Map(); |
| 63438 | target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); |
| 63439 | } |
| 63440 | var result = target.instantiations.get(id); |
| 63441 | if (!result) { |
| 63442 | var newMapper = createTypeMapper(typeParameters, typeArguments); |
| 63443 | result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : |
| 63444 | target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : |
| 63445 | instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); |
| 63446 | target.instantiations.set(id, result); |
| 63447 | } |
| 63448 | return result; |
| 63449 | } |
| 63450 | return type; |
| 63451 | } |
| 63452 | function maybeTypeParameterReference(node) { |
| 63453 | return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || |
| 63454 | node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); |
no test coverage detected