* Get type from type-reference that reference to class or interface
(node, symbol)
| 60263 | * Get type from type-reference that reference to class or interface |
| 60264 | */ |
| 60265 | function getTypeFromClassOrInterfaceReference(node, symbol) { |
| 60266 | var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); |
| 60267 | var typeParameters = type.localTypeParameters; |
| 60268 | if (typeParameters) { |
| 60269 | var numTypeArguments = ts.length(node.typeArguments); |
| 60270 | var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); |
| 60271 | var isJs = ts.isInJSFile(node); |
| 60272 | var isJsImplicitAny = !noImplicitAny && isJs; |
| 60273 | if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { |
| 60274 | var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); |
| 60275 | var diag = minTypeArgumentCount === typeParameters.length ? |
| 60276 | missingAugmentsTag ? |
| 60277 | ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : |
| 60278 | ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : |
| 60279 | missingAugmentsTag ? |
| 60280 | ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : |
| 60281 | ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; |
| 60282 | var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); |
| 60283 | error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); |
| 60284 | if (!isJs) { |
| 60285 | // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) |
| 60286 | return errorType; |
| 60287 | } |
| 60288 | } |
| 60289 | if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { |
| 60290 | return createDeferredTypeReference(type, node, /*mapper*/ undefined); |
| 60291 | } |
| 60292 | // In a type reference, the outer type parameters of the referenced class or interface are automatically |
| 60293 | // supplied as type arguments and the type reference only specifies arguments for the local type parameters |
| 60294 | // of the class or interface. |
| 60295 | var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); |
| 60296 | return createTypeReference(type, typeArguments); |
| 60297 | } |
| 60298 | return checkNoTypeArguments(node, symbol) ? type : errorType; |
| 60299 | } |
| 60300 | function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { |
| 60301 | var type = getDeclaredTypeOfSymbol(symbol); |
| 60302 | if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { |
no test coverage detected
searching dependent graphs…