From 07a696f7857b11c7e4c1e3caae8df9ab1adc8ca1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 26 May 2018 08:07:25 -0700 Subject: [PATCH] Rename existing unknownType to errorType --- src/compiler/checker.ts | 296 ++++++++++++++++++++-------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 769cde5dcc0..ebabed81818 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -99,7 +99,7 @@ namespace ts { getGlobalDiagnostics, getTypeOfSymbolAtLocation: (symbol, location) => { location = getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, getSymbolsOfParameterPropertyDeclaration: (parameterIn, parameterName) => { const parameter = getParseTreeNode(parameterIn, isParameter); @@ -117,7 +117,7 @@ namespace ts { getWidenedType, getTypeFromTypeNode: nodeIn => { const node = getParseTreeNode(nodeIn, isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature, @@ -152,7 +152,7 @@ namespace ts { }, getTypeAtLocation: node => { node = getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, getPropertySymbolOfDestructuringAssignment: locationIn => { const location = getParseTreeNode(locationIn, isIdentifier); @@ -353,7 +353,7 @@ namespace ts { const anyType = createIntrinsicType(TypeFlags.Any, "any"); const autoType = createIntrinsicType(TypeFlags.Any, "any"); const wildcardType = createIntrinsicType(TypeFlags.Any, "any"); - const unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); + const errorType = createIntrinsicType(TypeFlags.Any, "error"); const undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined"); const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsWideningType, "undefined"); const nullType = createIntrinsicType(TypeFlags.Null, "null"); @@ -398,7 +398,7 @@ namespace ts { const noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const resolvingSignaturesArray = [resolvingSignature]; @@ -4377,8 +4377,8 @@ namespace ts { const pattern = declaration.parent; let parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } // If no type was specified or inferred for parent, // infer from the initializer of the binding element if one is present. @@ -4395,7 +4395,7 @@ namespace ts { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } const literalMembers: PropertyName[] = []; for (const element of pattern.elements) { @@ -4453,7 +4453,7 @@ namespace ts { getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -4479,7 +4479,7 @@ namespace ts { else { error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } @@ -4631,7 +4631,7 @@ namespace ts { undefined; if (!expression) { - return unknownType; + return errorType; } const special = getSpecialPropertyAssignmentKind(expression); @@ -4657,7 +4657,7 @@ namespace ts { if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & SymbolFlags.JSContainer)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -4900,7 +4900,7 @@ namespace ts { } // Handle variable, parameter or property if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { - return unknownType; + return errorType; } let type: Type; @@ -4993,7 +4993,7 @@ namespace ts { } if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { - return unknownType; + return errorType; } let type: Type; @@ -5090,7 +5090,7 @@ namespace ts { // up recursively calling getTypeOfAlias, causing a stack overflow. links.type = targetSymbol.flags & SymbolFlags.Value ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -5100,11 +5100,11 @@ namespace ts { if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; let type = instantiateType(getTypeOfSymbol(links.target!), links.mapper!); @@ -5123,7 +5123,7 @@ namespace ts { if (getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } // Otherwise variable has initializer that circularly references the variable itself if (noImplicitAny) { @@ -5155,7 +5155,7 @@ namespace ts { if (symbol.flags & SymbolFlags.Alias) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type: Type, target: Type) { @@ -5330,7 +5330,7 @@ namespace ts { return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, TypeSystemPropertyName.ResolvedBaseConstructorType)) { - return unknownType; + return errorType; } const baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { @@ -5344,11 +5344,11 @@ namespace ts { } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & TypeFlags.Any) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -5407,7 +5407,7 @@ namespace ts { baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = emptyArray; } if (!isValidBaseType(baseType)) { @@ -5454,7 +5454,7 @@ namespace ts { if (declaration.kind === SyntaxKind.InterfaceDeclaration && getInterfaceBaseTypeNodes(declaration)) { for (const node of getInterfaceBaseTypeNodes(declaration)!) { const baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { @@ -5542,14 +5542,14 @@ namespace ts { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. if (!pushTypeResolution(symbol, TypeSystemPropertyName.DeclaredType)) { - return unknownType; + return errorType; } const declaration = find(symbol.declarations, d => isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration); const typeNode = isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. - let type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + let type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { const typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -5562,7 +5562,7 @@ namespace ts { } } else { - type = unknownType; + type = errorType; error(declaration.name, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -5687,7 +5687,7 @@ namespace ts { } function getDeclaredTypeOfSymbol(symbol: Symbol): Type { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol: Symbol): Type | undefined { @@ -6486,14 +6486,14 @@ namespace ts { function getConstraintTypeFromMappedType(type: MappedType) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type: MappedType) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & MappedTypeModifiers.IncludeOptional)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type: MappedType) { @@ -6666,7 +6666,7 @@ namespace ts { const objectType = getBaseConstraintOfType(type.objectType) || type.objectType; const indexType = getBaseConstraintOfType(type.indexType) || type.indexType; const constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type: ConditionalType) { @@ -6824,7 +6824,7 @@ namespace ts { const baseObjectType = getBaseConstraint((t).objectType); const baseIndexType = getBaseConstraint((t).indexType); const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } if (t.flags & TypeFlags.Conditional) { const constraint = getConstraintOfConditionalType(t); @@ -6918,7 +6918,7 @@ namespace ts { let checkFlags = 0; for (const current of containingType.types) { const type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { const prop = getPropertyOfType(type, name); const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -7456,7 +7456,7 @@ namespace ts { function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) { - return unknownType; + return errorType; } let type: Type; if (signature.target) { @@ -7759,7 +7759,7 @@ namespace ts { error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) - return unknownType; + return errorType; } } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -7768,7 +7768,7 @@ namespace ts { const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol: Symbol, typeArguments: Type[] | undefined): Type { @@ -7802,11 +7802,11 @@ namespace ts { symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined { @@ -7837,7 +7837,7 @@ namespace ts { function getTypeReferenceType(node: NodeWithTypeArguments, symbol: Symbol): Type { const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { - return unknownType; + return errorType; } const type = getTypeReferenceTypeWorker(node, symbol, typeArguments); @@ -7850,11 +7850,11 @@ namespace ts { if (res) { return checkNoTypeArguments(node, symbol) ? res.flags & TypeFlags.TypeParameter ? getConstrainedTypeVariable(res, node) : res : - unknownType; + errorType; } if (!(symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } const jsdocType = getJSDocTypeReference(node, symbol, typeArguments); @@ -8712,7 +8712,7 @@ namespace ts { case SyntaxKind.UniqueKeyword: links.resolvedType = node.type.kind === SyntaxKind.SymbolKeyword ? getESSymbolLikeTypeForNode(walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } @@ -8739,7 +8739,7 @@ namespace ts { markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === SyntaxKind.ThisKeyword); if (isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode!).resolvedSymbol = prop; @@ -8792,7 +8792,7 @@ namespace ts { error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type: Type): boolean { @@ -8912,8 +8912,8 @@ namespace ts { const propTypes: Type[] = []; for (const t of (indexType).types) { const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -9099,12 +9099,12 @@ namespace ts { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!isLiteralImportTypeNode(node)) { error(node.argument, Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } const argumentType = getTypeFromTypeNode(node.argument); const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; @@ -9113,7 +9113,7 @@ namespace ts { const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!nodeIsMissing(node.qualifier)) { @@ -9125,7 +9125,7 @@ namespace ts { const next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -9140,7 +9140,7 @@ namespace ts { else { error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } @@ -9371,7 +9371,7 @@ namespace ts { } } error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node: ThisExpression | ThisTypeNode): Type { @@ -9463,7 +9463,7 @@ namespace ts { const symbol = getSymbolAtLocation(node); return (symbol && getDeclaredTypeOfSymbol(symbol))!; // TODO: GH#18217 default: - return unknownType; + return errorType; } } @@ -13216,17 +13216,17 @@ namespace ts { return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type: Type, index: number) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index as __String) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type: Type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node: BinaryExpression): Type { @@ -13265,7 +13265,7 @@ namespace ts { case SyntaxKind.ForInStatement: return stringType; case SyntaxKind.ForOfStatement: - return checkRightHandSideOfForOf((parent).expression, (parent).awaitModifier) || unknownType; + return checkRightHandSideOfForOf((parent).expression, (parent).awaitModifier) || errorType; case SyntaxKind.BinaryExpression: return getAssignedTypeOfBinaryExpression(parent); case SyntaxKind.DeleteExpression: @@ -13279,7 +13279,7 @@ namespace ts { case SyntaxKind.ShorthandPropertyAssignment: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node: BindingElement): Type { @@ -13309,9 +13309,9 @@ namespace ts { return stringType; } if (node.parent.parent.kind === SyntaxKind.ForOfStatement) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node: VariableDeclaration | BindingElement) { @@ -13568,7 +13568,7 @@ namespace ts { const funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { const apparentType = getApparentType(funcType); - return apparentType !== unknownType && some(getSignaturesOfType(apparentType, SignatureKind.Call), signatureHasTypePredicate); + return apparentType !== errorType && some(getSignaturesOfType(apparentType, SignatureKind.Call), signatureHasTypePredicate); } } return false; @@ -13585,7 +13585,7 @@ namespace ts { let key: string | undefined; let flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; @@ -13609,7 +13609,7 @@ namespace ts { // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -14341,7 +14341,7 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. @@ -14419,11 +14419,11 @@ namespace ts { if (!(localOrExportSymbol.flags & SymbolFlags.Variable) && !(isInJavaScriptFile(node) && localOrExportSymbol.flags & SymbolFlags.ValueModule)) { error(node, Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } @@ -14740,7 +14740,7 @@ namespace ts { if (isInJavaScriptFile(node)) { const type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } @@ -14798,7 +14798,7 @@ namespace ts { else { error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } if (!isCallExpression && container.kind === SyntaxKind.Constructor) { @@ -14889,7 +14889,7 @@ namespace ts { if (container.parent.kind === SyntaxKind.ObjectLiteralExpression) { if (languageVersion < ScriptTarget.ES2015) { error(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); - return unknownType; + return errorType; } else { // for object literal assume that type of 'super' is 'any' @@ -14901,19 +14901,19 @@ namespace ts { const classLikeDeclaration = container.parent; if (!getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); const baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; + return errorType; } return nodeCheckFlag === NodeCheckFlags.SuperStatic @@ -15517,7 +15517,7 @@ namespace ts { // var CustomTag: "h1" = "h1"; // Hello World const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { const stringLiteralTypeName = (valueType).value; const intrinsicProp = getPropertyOfType(intrinsicElementsType, escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -15540,7 +15540,7 @@ namespace ts { ctor = false; if (signatures.length === 0) { // We found no signatures at all, which is an error - return unknownType; + return errorType; } } @@ -15564,7 +15564,7 @@ namespace ts { function getJsxPropsTypeFromCallSignature(sig: Signature, context: Node) { let propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -15601,7 +15601,7 @@ namespace ts { // Normal case -- add in IntrinsicClassElements and IntrinsicElements let apparentAttributesType = attributesType; const intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { const typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); const hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes( @@ -15613,7 +15613,7 @@ namespace ts { } const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } @@ -15991,7 +15991,7 @@ namespace ts { const type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); offset = i + 1; @@ -16278,7 +16278,7 @@ namespace ts { const namespace = getJsxNamespaceAt(location); const exports = namespace && getExportsOfSymbol(namespace); const typeSymbol = exports && getSymbol(exports, name, SymbolFlags.Type); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -16291,7 +16291,7 @@ namespace ts { const links = getNodeLinks(node); if (!links.resolvedSymbol) { const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { // Property case if (!isIdentifier(node.tagName)) return Debug.fail(); const intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); @@ -16468,7 +16468,7 @@ namespace ts { if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -16528,7 +16528,7 @@ namespace ts { } // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -16615,7 +16615,7 @@ namespace ts { // var CustomTag: "h1" = "h1"; // Hello World const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { const stringLiteralTypeName = (elementType).value; const intrinsicProp = getPropertyOfType(intrinsicElementsType, escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -16635,7 +16635,7 @@ namespace ts { const instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); if (!length(instantiatedSignatures)) { - return unknownType; + return errorType; } const elemInstanceType = getUnionType(instantiatedSignatures!.map(getReturnTypeOfSignature), UnionReduction.Subtype); @@ -16675,7 +16675,7 @@ namespace ts { return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, IndexKind.String)!.type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -16734,7 +16734,7 @@ namespace ts { function getJsxElementClassTypeAt(location: Node): Type | undefined { const type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) return undefined; + if (type === errorType) return undefined; return type; } @@ -16915,7 +16915,7 @@ namespace ts { return type; } else { - return unknownType; + return errorType; } } @@ -17086,7 +17086,7 @@ namespace ts { (nullDiagnostic || Diagnostics.Object_is_possibly_null) ); const t = getNonNullableType(type); - return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? unknownType : t; + return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? errorType : t; } return type; } @@ -17121,7 +17121,7 @@ namespace ts { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, leftType.flags & TypeFlags.TypeParameter && (leftType as TypeParameter).isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (isAssignmentTarget(node) || isDeleteTarget(node))) { error(node, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -17136,7 +17136,7 @@ namespace ts { if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); @@ -17441,7 +17441,7 @@ namespace ts { propertyName: __String, type: Type): boolean { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } const prop = getPropertyOfType(type, propertyName); @@ -17516,25 +17516,25 @@ namespace ts { const end = node.end; grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Expression_expected); } - return unknownType; + return errorType; } const indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== SyntaxKind.StringLiteral) { error(indexExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { - if (expressionType === unknownType) { + if (expressionType === errorType) { // There is already an error, so no need to report one. return false; } @@ -18133,7 +18133,7 @@ namespace ts { } Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** @@ -18155,7 +18155,7 @@ namespace ts { // The second argument to a decorator is its `propertyKey` if (node.kind === SyntaxKind.ClassDeclaration) { Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } if (node.kind === SyntaxKind.Parameter) { @@ -18197,12 +18197,12 @@ namespace ts { default: Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** @@ -18217,7 +18217,7 @@ namespace ts { // or its `parameterIndex` for a parameter decorator if (node.kind === SyntaxKind.ClassDeclaration) { Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } if (node.kind === SyntaxKind.Parameter) { @@ -18227,7 +18227,7 @@ namespace ts { if (node.kind === SyntaxKind.PropertyDeclaration) { Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } if (node.kind === SyntaxKind.MethodDeclaration || @@ -18240,7 +18240,7 @@ namespace ts { } Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** @@ -18258,7 +18258,7 @@ namespace ts { } Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } /** @@ -18602,7 +18602,7 @@ namespace ts { if (isTypeAny(superType)) { return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. const baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)!); @@ -18626,7 +18626,7 @@ namespace ts { } const apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -18644,7 +18644,7 @@ namespace ts { if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -18694,7 +18694,7 @@ namespace ts { // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -18820,7 +18820,7 @@ namespace ts { const tagType = checkExpression(node.tag); const apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -18871,7 +18871,7 @@ namespace ts { function resolveDecorator(node: Decorator, candidatesOutArray: Signature[] | undefined): Signature { const funcType = checkExpression(node.expression); const apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } @@ -19173,7 +19173,7 @@ namespace ts { } function getTypeWithSyntheticDefaultImportType(type: Type, symbol: Symbol, originalSymbol: Symbol): Type { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { const synthType = type as SyntheticDefaultModuleType; if (!synthType.syntheticType) { const file = find(originalSymbol.declarations, isSourceFile); @@ -19244,7 +19244,7 @@ namespace ts { checkSourceElement(type); const targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { const widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -19275,7 +19275,7 @@ namespace ts { const container = getNewTargetContainer(node); if (!container) { error(node, Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } else if (container.kind === SyntaxKind.Constructor) { const symbol = getSymbolOfNode(container.parent as ClassLikeDeclaration); @@ -19294,7 +19294,7 @@ namespace ts { const file = getSourceFileOfNode(node); Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag."); Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol: Symbol) { @@ -19413,7 +19413,7 @@ namespace ts { error(func, isImportCall(func) ? Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, isImportCall(func) ? @@ -19426,7 +19426,7 @@ namespace ts { function getReturnTypeFromBody(func: FunctionLikeDeclaration, checkMode?: CheckMode): Type { if (!func.body) { - return unknownType; + return errorType; } const functionFlags = getFunctionFlags(func); @@ -19912,7 +19912,7 @@ namespace ts { } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { @@ -20089,7 +20089,7 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; for (let i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -20340,7 +20340,7 @@ namespace ts { else if (isTypeAny(leftType) || isTypeAny(rightType)) { // Otherwise, the result is of type Any. // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } // Symbols are not allowed at all in arithmetic expressions @@ -20888,7 +20888,7 @@ namespace ts { case SyntaxKind.JsxOpeningElement: Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } // DECLARATION AND STATEMENT TYPE CHECKING @@ -21501,7 +21501,7 @@ namespace ts { function getTypeParametersForTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments) { const type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { const symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & SymbolFlags.TypeAlias && getSymbolLinks(symbol).typeParameters || @@ -21517,7 +21517,7 @@ namespace ts { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } const type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved forEach(node.typeArguments, checkSourceElement); @@ -22057,7 +22057,7 @@ namespace ts { * The runtime behavior of the `await` keyword. */ function checkAwaitedType(type: Type, errorNode: Node, diagnosticMessage: DiagnosticMessage): Type { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type: Type, errorNode?: Node, diagnosticMessage?: DiagnosticMessage): Type | undefined { @@ -22206,41 +22206,41 @@ namespace ts { const returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= ScriptTarget.ES2015) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } const globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. error(returnTypeNode, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { // Always mark the type node as referenced if it points to a value markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } const promiseConstructorSymbol = resolveEntityName(promiseConstructorName, SymbolFlags.Value, /*ignoreErrors*/ true); - const promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + const promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === SyntaxKind.Identifier && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { error(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } const globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); @@ -22248,12 +22248,12 @@ namespace ts { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. error(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } // Verify there is no local declaration that could collide with the promise constructor. @@ -22263,7 +22263,7 @@ namespace ts { error(collidingSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, idText(rootName), entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } @@ -23260,7 +23260,7 @@ namespace ts { // initializer is consistent with type associated with the node const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & SymbolFlags.JSContainer)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -23428,7 +23428,7 @@ namespace ts { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { const leftType = checkExpression(varExpr); @@ -24348,7 +24348,7 @@ namespace ts { checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { const genericDiag = t.symbol && t.symbol.flags & SymbolFlags.Class ? Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -26211,7 +26211,7 @@ namespace ts { function getTypeOfNode(node: Node): Type | undefined { if (node.flags & NodeFlags.InWithStatement) { // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; + return errorType; } if (isPartOfTypeNode(node)) { @@ -26269,11 +26269,11 @@ namespace ts { const symbol = getSymbolAtLocation(node); if (symbol) { const declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } // Gets the type of object literal or array literal of destructuring assignment. @@ -26289,27 +26289,27 @@ namespace ts { // } if (expr.parent.kind === SyntaxKind.ForOfStatement) { const iteratedType = checkRightHandSideOfForOf((expr.parent).expression, (expr.parent).awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } if (expr.parent.kind === SyntaxKind.BinaryExpression) { const iteratedType = getTypeOfExpression((expr.parent).right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { if (expr.parent.kind === SyntaxKind.PropertyAssignment) { const typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent)!; // TODO: GH#18217 + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent)!; // TODO: GH#18217 } // Array literal assignment - array destructuring pattern Debug.assert(expr.parent.kind === SyntaxKind.ArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; const typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, - (expr.parent).elements.indexOf(expr), elementType || unknownType)!; // TODO: GH#18217 + (expr.parent).elements.indexOf(expr), elementType || errorType)!; // TODO: GH#18217 } // Gets the property symbol corresponding to the property in destructuring assignment @@ -26732,7 +26732,7 @@ namespace ts { return TypeReferenceSerializationKind.Unknown; } const type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { + if (type === errorType) { return TypeReferenceSerializationKind.Unknown; } else if (type.flags & TypeFlags.Any) { @@ -26776,7 +26776,7 @@ namespace ts { const symbol = getSymbolOfNode(declaration); let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; + : errorType; if (type.flags & TypeFlags.UniqueESSymbol && type.symbol === symbol) { flags |= NodeBuilderFlags.AllowUniqueESSymbolType; @@ -27087,7 +27087,7 @@ namespace ts { getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments" as __String, /*arity*/ 0, /*reportErrors*/ true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; // Initialize special types globalArrayType = getGlobalType("Array" as __String, /*arity*/ 1, /*reportErrors*/ true);