(type)
| 57205 | return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); |
| 57206 | } |
| 57207 | function resolveBaseTypesOfClass(type) { |
| 57208 | type.resolvedBaseTypes = ts.resolvingEmptyArray; |
| 57209 | var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); |
| 57210 | if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { |
| 57211 | return type.resolvedBaseTypes = ts.emptyArray; |
| 57212 | } |
| 57213 | var baseTypeNode = getBaseTypeNodeOfClass(type); |
| 57214 | var baseType; |
| 57215 | var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; |
| 57216 | if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && |
| 57217 | areAllOuterTypeParametersApplied(originalBaseType)) { |
| 57218 | // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the |
| 57219 | // class and all return the instance type of the class. There is no need for further checks and we can apply the |
| 57220 | // type arguments in the same manner as a type reference to get the same error reporting experience. |
| 57221 | baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); |
| 57222 | } |
| 57223 | else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { |
| 57224 | baseType = baseConstructorType; |
| 57225 | } |
| 57226 | else { |
| 57227 | // The class derives from a "class-like" constructor function, check that we have at least one construct signature |
| 57228 | // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere |
| 57229 | // we check that all instantiated signatures return the same type. |
| 57230 | var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); |
| 57231 | if (!constructors.length) { |
| 57232 | error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); |
| 57233 | return type.resolvedBaseTypes = ts.emptyArray; |
| 57234 | } |
| 57235 | baseType = getReturnTypeOfSignature(constructors[0]); |
| 57236 | } |
| 57237 | if (isErrorType(baseType)) { |
| 57238 | return type.resolvedBaseTypes = ts.emptyArray; |
| 57239 | } |
| 57240 | var reducedBaseType = getReducedType(baseType); |
| 57241 | if (!isValidBaseType(reducedBaseType)) { |
| 57242 | var elaboration = elaborateNeverIntersection(/*errorInfo*/ undefined, baseType); |
| 57243 | var diagnostic = ts.chainDiagnosticMessages(elaboration, ts.Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(reducedBaseType)); |
| 57244 | diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic)); |
| 57245 | return type.resolvedBaseTypes = ts.emptyArray; |
| 57246 | } |
| 57247 | if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { |
| 57248 | error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); |
| 57249 | return type.resolvedBaseTypes = ts.emptyArray; |
| 57250 | } |
| 57251 | if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { |
| 57252 | // Circular reference, likely through instantiation of default parameters |
| 57253 | // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset |
| 57254 | // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a |
| 57255 | // partial instantiation of the members without the base types fully resolved |
| 57256 | type.members = undefined; |
| 57257 | } |
| 57258 | return type.resolvedBaseTypes = [reducedBaseType]; |
| 57259 | } |
| 57260 | function areAllOuterTypeParametersApplied(type) { |
| 57261 | // An unapplied type parameter has its symbol still the same as the matching argument symbol. |
| 57262 | // Since parameters are applied outer-to-inner, only the last outer parameter needs to be checked. |
no test coverage detected
searching dependent graphs…