typescript 4.5.0-dev.20210923 → 4.5.0-dev.20210924

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20210923";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20210924";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -4723,6 +4723,7 @@ var ts;
4723
4723
  CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType";
4724
4724
  CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped";
4725
4725
  CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional";
4726
+ CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved";
4726
4727
  CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
4727
4728
  CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant";
4728
4729
  CheckFlags[CheckFlags["Partial"] = 48] = "Partial";
@@ -46424,10 +46425,13 @@ var ts;
46424
46425
  var undefinedProperties = new ts.Map();
46425
46426
  var unknownSymbol = createSymbol(4 /* Property */, "unknown");
46426
46427
  var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
46428
+ var unresolvedSymbols = new ts.Map();
46429
+ var errorTypes = new ts.Map();
46427
46430
  var anyType = createIntrinsicType(1 /* Any */, "any");
46428
46431
  var autoType = createIntrinsicType(1 /* Any */, "any");
46429
46432
  var wildcardType = createIntrinsicType(1 /* Any */, "any");
46430
46433
  var errorType = createIntrinsicType(1 /* Any */, "error");
46434
+ var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
46431
46435
  var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
46432
46436
  var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
46433
46437
  var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
@@ -49866,7 +49870,9 @@ var ts;
49866
49870
  var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
49867
49871
  if (typeNode === undefined)
49868
49872
  return ts.Debug.fail("should always get typenode");
49869
- var options = { removeComments: true };
49873
+ // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
49874
+ // Otherwise, we always strip comments out.
49875
+ var options = { removeComments: type !== unresolvedType };
49870
49876
  var printer = ts.createPrinter(options);
49871
49877
  var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
49872
49878
  printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
@@ -50011,6 +50017,12 @@ var ts;
50011
50017
  type = getReducedType(type);
50012
50018
  }
50013
50019
  if (type.flags & 1 /* Any */) {
50020
+ if (type.aliasSymbol) {
50021
+ return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
50022
+ }
50023
+ if (type === unresolvedType) {
50024
+ return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
50025
+ }
50014
50026
  context.approximateLength += 3;
50015
50027
  return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
50016
50028
  }
@@ -51099,6 +51111,10 @@ var ts;
51099
51111
  }
51100
51112
  return specifier;
51101
51113
  }
51114
+ function symbolToEntityNameNode(symbol) {
51115
+ var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
51116
+ return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
51117
+ }
51102
51118
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
51103
51119
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
51104
51120
  var isTypeOf = meaning === 111551 /* Value */;
@@ -51385,7 +51401,7 @@ var ts;
51385
51401
  * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
51386
51402
  */
51387
51403
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
51388
- if (type !== errorType && enclosingDeclaration) {
51404
+ if (!isErrorType(type) && enclosingDeclaration) {
51389
51405
  var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
51390
51406
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
51391
51407
  // try to reuse the existing annotation
@@ -51408,7 +51424,7 @@ var ts;
51408
51424
  return result;
51409
51425
  }
51410
51426
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
51411
- if (type !== errorType && context.enclosingDeclaration) {
51427
+ if (!isErrorType(type) && context.enclosingDeclaration) {
51412
51428
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
51413
51429
  if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
51414
51430
  var annotated = getTypeFromTypeNode(annotation);
@@ -51515,7 +51531,7 @@ var ts;
51515
51531
  /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
51516
51532
  }
51517
51533
  }
51518
- if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) {
51534
+ if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
51519
51535
  return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51520
51536
  }
51521
51537
  if (ts.isLiteralImportTypeNode(node)) {
@@ -53143,6 +53159,11 @@ var ts;
53143
53159
  function isTypeAny(type) {
53144
53160
  return type && (type.flags & 1 /* Any */) !== 0;
53145
53161
  }
53162
+ function isErrorType(type) {
53163
+ // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
53164
+ // a reference to an unresolved symbol. We want those to behave like the errorType.
53165
+ return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
53166
+ }
53146
53167
  // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
53147
53168
  // assigned by contextual typing.
53148
53169
  function getTypeForBindingElementParent(node) {
@@ -53660,7 +53681,7 @@ var ts;
53660
53681
  if (!declaredType) {
53661
53682
  return type;
53662
53683
  }
53663
- else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
53684
+ else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
53664
53685
  errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
53665
53686
  }
53666
53687
  }
@@ -54554,7 +54575,7 @@ var ts;
54554
54575
  for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
54555
54576
  var node = implementsTypeNodes_1[_b];
54556
54577
  var implementsType = getTypeFromTypeNode(node);
54557
- if (implementsType !== errorType) {
54578
+ if (!isErrorType(implementsType)) {
54558
54579
  if (resolvedImplementsTypes === ts.emptyArray) {
54559
54580
  resolvedImplementsTypes = [implementsType];
54560
54581
  }
@@ -54634,7 +54655,7 @@ var ts;
54634
54655
  }
54635
54656
  baseType = getReturnTypeOfSignature(constructors[0]);
54636
54657
  }
54637
- if (baseType === errorType) {
54658
+ if (isErrorType(baseType)) {
54638
54659
  return type.resolvedBaseTypes = ts.emptyArray;
54639
54660
  }
54640
54661
  var reducedBaseType = getReducedType(baseType);
@@ -54690,7 +54711,7 @@ var ts;
54690
54711
  for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
54691
54712
  var node = _c[_b];
54692
54713
  var baseType = getReducedType(getTypeFromTypeNode(node));
54693
- if (baseType !== errorType) {
54714
+ if (!isErrorType(baseType)) {
54694
54715
  if (isValidBaseType(baseType)) {
54695
54716
  if (type !== baseType && !hasBaseType(baseType, type)) {
54696
54717
  if (type.resolvedBaseTypes === ts.emptyArray) {
@@ -56532,7 +56553,7 @@ var ts;
56532
56553
  for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
56533
56554
  var current = _c[_i];
56534
56555
  var type = getApparentType(current);
56535
- if (!(type === errorType || type.flags & 131072 /* Never */)) {
56556
+ if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
56536
56557
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
56537
56558
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
56538
56559
  if (prop) {
@@ -57482,7 +57503,7 @@ var ts;
57482
57503
  }
57483
57504
  else {
57484
57505
  var type = getTypeFromTypeNode(constraintDeclaration);
57485
- if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed
57506
+ if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
57486
57507
  // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
57487
57508
  // use unknown otherwise
57488
57509
  type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
@@ -57654,6 +57675,18 @@ var ts;
57654
57675
  * declared type. Instantiations are cached using the type identities of the type arguments as the key.
57655
57676
  */
57656
57677
  function getTypeFromTypeAliasReference(node, symbol) {
57678
+ if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
57679
+ var typeArguments = typeArgumentsFromTypeReferenceNode(node);
57680
+ var id = getAliasId(symbol, typeArguments);
57681
+ var errorType_1 = errorTypes.get(id);
57682
+ if (!errorType_1) {
57683
+ errorType_1 = createIntrinsicType(1 /* Any */, "error");
57684
+ errorType_1.aliasSymbol = symbol;
57685
+ errorType_1.aliasTypeArguments = typeArguments;
57686
+ errorTypes.set(id, errorType_1);
57687
+ }
57688
+ return errorType_1;
57689
+ }
57657
57690
  var type = getDeclaredTypeOfSymbol(symbol);
57658
57691
  var typeParameters = getSymbolLinks(symbol).typeParameters;
57659
57692
  if (typeParameters) {
@@ -57695,11 +57728,37 @@ var ts;
57695
57728
  }
57696
57729
  return undefined;
57697
57730
  }
57698
- function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
57699
- if (!typeReferenceName) {
57731
+ function getSymbolPath(symbol) {
57732
+ return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
57733
+ }
57734
+ function getUnresolvedSymbolForEntityName(name) {
57735
+ var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
57736
+ name.kind === 205 /* PropertyAccessExpression */ ? name.name :
57737
+ name;
57738
+ var text = identifier.escapedText;
57739
+ if (text) {
57740
+ var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
57741
+ name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
57742
+ undefined;
57743
+ var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
57744
+ var result = unresolvedSymbols.get(path);
57745
+ if (!result) {
57746
+ unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
57747
+ result.parent = parentSymbol;
57748
+ result.declaredType = unresolvedType;
57749
+ }
57750
+ return result;
57751
+ }
57752
+ return unknownSymbol;
57753
+ }
57754
+ function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
57755
+ var name = getTypeReferenceName(typeReference);
57756
+ if (!name) {
57700
57757
  return unknownSymbol;
57701
57758
  }
57702
- return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
57759
+ var symbol = resolveEntityName(name, meaning, ignoreErrors);
57760
+ return symbol && symbol !== unknownSymbol ? symbol :
57761
+ ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
57703
57762
  }
57704
57763
  function getTypeReferenceType(node, symbol) {
57705
57764
  if (symbol === unknownSymbol) {
@@ -57724,7 +57783,7 @@ var ts;
57724
57783
  }
57725
57784
  else {
57726
57785
  // Resolve the type reference as a Type for the purpose of reporting errors.
57727
- resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */);
57786
+ resolveTypeReferenceName(node, 788968 /* Type */);
57728
57787
  return getTypeOfSymbol(symbol);
57729
57788
  }
57730
57789
  }
@@ -57868,18 +57927,18 @@ var ts;
57868
57927
  if (isJSDocTypeReference(node)) {
57869
57928
  type = getIntendedTypeFromJSDocTypeReference(node);
57870
57929
  if (!type) {
57871
- symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true);
57930
+ symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
57872
57931
  if (symbol === unknownSymbol) {
57873
- symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */);
57932
+ symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
57874
57933
  }
57875
57934
  else {
57876
- resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any
57935
+ resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
57877
57936
  }
57878
57937
  type = getTypeReferenceType(node, symbol);
57879
57938
  }
57880
57939
  }
57881
57940
  if (!type) {
57882
- symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
57941
+ symbol = resolveTypeReferenceName(node, meaning);
57883
57942
  type = getTypeReferenceType(node, symbol);
57884
57943
  }
57885
57944
  // Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
@@ -58140,7 +58199,7 @@ var ts;
58140
58199
  function mayResolveTypeAlias(node) {
58141
58200
  switch (node.kind) {
58142
58201
  case 177 /* TypeReference */:
58143
- return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */);
58202
+ return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
58144
58203
  case 180 /* TypeQuery */:
58145
58204
  return true;
58146
58205
  case 192 /* TypeOperator */:
@@ -60669,7 +60728,7 @@ var ts;
60669
60728
  var mappedTypeVariable = instantiateType(typeVariable, mapper);
60670
60729
  if (typeVariable !== mappedTypeVariable) {
60671
60730
  return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
60672
- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) {
60731
+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
60673
60732
  if (!type.declaration.nameType) {
60674
60733
  if (isArrayType(t)) {
60675
60734
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
@@ -60711,7 +60770,7 @@ var ts;
60711
60770
  }
60712
60771
  function instantiateMappedArrayType(arrayType, mappedType, mapper) {
60713
60772
  var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
60714
- return elementType === errorType ? errorType :
60773
+ return isErrorType(elementType) ? errorType :
60715
60774
  createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
60716
60775
  }
60717
60776
  function instantiateMappedTupleType(tupleType, mappedType, mapper) {
@@ -62293,7 +62352,7 @@ var ts;
62293
62352
  var targetTypes = target.types;
62294
62353
  var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
62295
62354
  var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
62296
- if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
62355
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
62297
62356
  (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
62298
62357
  // do not report top error
62299
62358
  return result;
@@ -69270,8 +69329,7 @@ var ts;
69270
69329
  if (result) {
69271
69330
  return result;
69272
69331
  }
69273
- if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
69274
- // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
69332
+ if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
69275
69333
  return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
69276
69334
  }
69277
69335
  }
@@ -69852,7 +69910,7 @@ var ts;
69852
69910
  var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
69853
69911
  propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
69854
69912
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
69855
- if (intrinsicAttribs !== errorType) {
69913
+ if (!isErrorType(intrinsicAttribs)) {
69856
69914
  propsType = intersectTypes(intrinsicAttribs, propsType);
69857
69915
  }
69858
69916
  return propsType;
@@ -69945,7 +70003,7 @@ var ts;
69945
70003
  // Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
69946
70004
  var apparentAttributesType = attributesType;
69947
70005
  var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
69948
- if (intrinsicClassAttribs !== errorType) {
70006
+ if (!isErrorType(intrinsicClassAttribs)) {
69949
70007
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
69950
70008
  var hostClassType = getReturnTypeOfSignature(sig);
69951
70009
  apparentAttributesType = intersectTypes(typeParams
@@ -69953,7 +70011,7 @@ var ts;
69953
70011
  : intrinsicClassAttribs, apparentAttributesType);
69954
70012
  }
69955
70013
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
69956
- if (intrinsicAttribs !== errorType) {
70014
+ if (!isErrorType(intrinsicAttribs)) {
69957
70015
  apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
69958
70016
  }
69959
70017
  return apparentAttributesType;
@@ -70421,7 +70479,7 @@ var ts;
70421
70479
  checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
70422
70480
  }
70423
70481
  offset = propertiesArray.length;
70424
- if (spread === errorType) {
70482
+ if (isErrorType(spread)) {
70425
70483
  continue;
70426
70484
  }
70427
70485
  spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
@@ -70478,7 +70536,7 @@ var ts;
70478
70536
  }
70479
70537
  }
70480
70538
  }
70481
- if (spread === errorType) {
70539
+ if (isErrorType(spread)) {
70482
70540
  return errorType;
70483
70541
  }
70484
70542
  if (spread !== emptyObjectType) {
@@ -70745,7 +70803,7 @@ var ts;
70745
70803
  var links = getNodeLinks(node);
70746
70804
  if (!links.resolvedSymbol) {
70747
70805
  var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
70748
- if (intrinsicElementsType !== errorType) {
70806
+ if (!isErrorType(intrinsicElementsType)) {
70749
70807
  // Property case
70750
70808
  if (!ts.isIdentifier(node.tagName))
70751
70809
  return ts.Debug.fail();
@@ -70908,7 +70966,7 @@ var ts;
70908
70966
  // var CustomTag: "h1" = "h1";
70909
70967
  // <CustomTag> Hello World </CustomTag>
70910
70968
  var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
70911
- if (intrinsicElementsType !== errorType) {
70969
+ if (!isErrorType(intrinsicElementsType)) {
70912
70970
  var stringLiteralTypeName = type.value;
70913
70971
  var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
70914
70972
  if (intrinsicProp) {
@@ -70976,7 +71034,7 @@ var ts;
70976
71034
  }
70977
71035
  function getJsxElementClassTypeAt(location) {
70978
71036
  var type = getJsxType(JsxNames.ElementClass, location);
70979
- if (type === errorType)
71037
+ if (isErrorType(type))
70980
71038
  return undefined;
70981
71039
  return type;
70982
71040
  }
@@ -71282,7 +71340,7 @@ var ts;
71282
71340
  }
71283
71341
  function checkNonNullNonVoidType(type, node) {
71284
71342
  var nonNullType = checkNonNullType(type, node);
71285
- if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) {
71343
+ if (nonNullType.flags & 16384 /* Void */) {
71286
71344
  error(node, ts.Diagnostics.Object_is_possibly_undefined);
71287
71345
  }
71288
71346
  return nonNullType;
@@ -71399,7 +71457,7 @@ var ts;
71399
71457
  }
71400
71458
  if (isAnyLike) {
71401
71459
  if (lexicallyScopedSymbol) {
71402
- return apparentType;
71460
+ return isErrorType(apparentType) ? errorType : apparentType;
71403
71461
  }
71404
71462
  if (!ts.getContainingClass(right)) {
71405
71463
  grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -71423,7 +71481,8 @@ var ts;
71423
71481
  if (ts.isIdentifier(left) && parentSymbol) {
71424
71482
  markAliasReferenced(parentSymbol, node);
71425
71483
  }
71426
- return apparentType;
71484
+ return isErrorType(apparentType) ? errorType : apparentType;
71485
+ ;
71427
71486
  }
71428
71487
  prop = getPropertyOfType(apparentType, right.escapedText);
71429
71488
  }
@@ -71882,7 +71941,7 @@ var ts;
71882
71941
  }
71883
71942
  function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
71884
71943
  // Short-circuiting for improved performance.
71885
- if (type === errorType || isTypeAny(type)) {
71944
+ if (isTypeAny(type)) {
71886
71945
  return true;
71887
71946
  }
71888
71947
  var prop = getPropertyOfType(type, propertyName);
@@ -71900,7 +71959,7 @@ var ts;
71900
71959
  */
71901
71960
  function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
71902
71961
  // Short-circuiting for improved performance.
71903
- if (containingType === errorType || isTypeAny(containingType)) {
71962
+ if (isTypeAny(containingType)) {
71904
71963
  return true;
71905
71964
  }
71906
71965
  // A #private property access in an optional chain is an error dealt with by the parser.
@@ -71971,7 +72030,7 @@ var ts;
71971
72030
  var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
71972
72031
  var indexExpression = node.argumentExpression;
71973
72032
  var indexType = checkExpression(indexExpression);
71974
- if (objectType === errorType || objectType === silentNeverType) {
72033
+ if (isErrorType(objectType) || objectType === silentNeverType) {
71975
72034
  return objectType;
71976
72035
  }
71977
72036
  if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
@@ -72216,7 +72275,7 @@ var ts;
72216
72275
  // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
72217
72276
  // return type of 'wrap'.
72218
72277
  if (node.kind !== 164 /* Decorator */) {
72219
- var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
72278
+ var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
72220
72279
  if (contextualType) {
72221
72280
  // We clone the inference context to avoid disturbing a resolution in progress for an
72222
72281
  // outer call expression. Effectively we just want a snapshot of whatever has been
@@ -73165,7 +73224,7 @@ var ts;
73165
73224
  }
73166
73225
  return anySignature;
73167
73226
  }
73168
- if (superType !== errorType) {
73227
+ if (!isErrorType(superType)) {
73169
73228
  // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
73170
73229
  // with the type arguments specified in the extends clause.
73171
73230
  var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
@@ -73193,7 +73252,7 @@ var ts;
73193
73252
  return silentNeverSignature;
73194
73253
  }
73195
73254
  var apparentType = getApparentType(funcType);
73196
- if (apparentType === errorType) {
73255
+ if (isErrorType(apparentType)) {
73197
73256
  // Another error has already been reported
73198
73257
  return resolveErrorCall(node);
73199
73258
  }
@@ -73209,7 +73268,7 @@ var ts;
73209
73268
  if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
73210
73269
  // The unknownType indicates that an error already occurred (and was reported). No
73211
73270
  // need to report another error in this case.
73212
- if (funcType !== errorType && node.typeArguments) {
73271
+ if (!isErrorType(funcType) && node.typeArguments) {
73213
73272
  error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
73214
73273
  }
73215
73274
  return resolveUntypedCall(node);
@@ -73286,7 +73345,7 @@ var ts;
73286
73345
  // signatures for overload resolution. The result type of the function call becomes
73287
73346
  // the result type of the operation.
73288
73347
  expressionType = getApparentType(expressionType);
73289
- if (expressionType === errorType) {
73348
+ if (isErrorType(expressionType)) {
73290
73349
  // Another error has already been reported
73291
73350
  return resolveErrorCall(node);
73292
73351
  }
@@ -73501,7 +73560,7 @@ var ts;
73501
73560
  function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
73502
73561
  var tagType = checkExpression(node.tag);
73503
73562
  var apparentType = getApparentType(tagType);
73504
- if (apparentType === errorType) {
73563
+ if (isErrorType(apparentType)) {
73505
73564
  // Another error has already been reported
73506
73565
  return resolveErrorCall(node);
73507
73566
  }
@@ -73547,7 +73606,7 @@ var ts;
73547
73606
  function resolveDecorator(node, candidatesOutArray, checkMode) {
73548
73607
  var funcType = checkExpression(node.expression);
73549
73608
  var apparentType = getApparentType(funcType);
73550
- if (apparentType === errorType) {
73609
+ if (isErrorType(apparentType)) {
73551
73610
  return resolveErrorCall(node);
73552
73611
  }
73553
73612
  var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
@@ -73602,7 +73661,7 @@ var ts;
73602
73661
  }
73603
73662
  var exprTypes = checkExpression(node.tagName);
73604
73663
  var apparentType = getApparentType(exprTypes);
73605
- if (apparentType === errorType) {
73664
+ if (isErrorType(apparentType)) {
73606
73665
  return resolveErrorCall(node);
73607
73666
  }
73608
73667
  var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
@@ -73925,7 +73984,7 @@ var ts;
73925
73984
  }
73926
73985
  function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
73927
73986
  var _a;
73928
- if (allowSyntheticDefaultImports && type && type !== errorType) {
73987
+ if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
73929
73988
  var synthType = type;
73930
73989
  if (!synthType.syntheticType) {
73931
73990
  var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
@@ -74031,7 +74090,7 @@ var ts;
74031
74090
  checkSourceElement(type);
74032
74091
  exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
74033
74092
  var targetType = getTypeFromTypeNode(type);
74034
- if (produceDiagnostics && targetType !== errorType) {
74093
+ if (produceDiagnostics && !isErrorType(targetType)) {
74035
74094
  var widenedType = getWidenedType(exprType);
74036
74095
  if (!isTypeComparableTo(targetType, widenedType)) {
74037
74096
  checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
@@ -74064,7 +74123,7 @@ var ts;
74064
74123
  return getGlobalImportMetaExpressionType();
74065
74124
  case 103 /* NewKeyword */:
74066
74125
  var type = checkNewTargetMetaProperty(node);
74067
- return type === errorType ? errorType : createNewTargetExpressionType(type);
74126
+ return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
74068
74127
  default:
74069
74128
  ts.Debug.assertNever(node.keywordToken);
74070
74129
  }
@@ -75057,7 +75116,7 @@ var ts;
75057
75116
  }
75058
75117
  var operandType = checkExpression(node.expression);
75059
75118
  var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
75060
- if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) {
75119
+ if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
75061
75120
  addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
75062
75121
  }
75063
75122
  return awaitedType;
@@ -75698,7 +75757,7 @@ var ts;
75698
75757
  else if (isTypeAny(leftType) || isTypeAny(rightType)) {
75699
75758
  // Otherwise, the result is of type Any.
75700
75759
  // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
75701
- resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
75760
+ resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
75702
75761
  }
75703
75762
  // Symbols are not allowed at all in arithmetic expressions
75704
75763
  if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
@@ -77176,7 +77235,7 @@ var ts;
77176
77235
  }
77177
77236
  function getTypeParametersForTypeReference(node) {
77178
77237
  var type = getTypeFromTypeReference(node);
77179
- if (type !== errorType) {
77238
+ if (!isErrorType(type)) {
77180
77239
  var symbol = getNodeLinks(node).resolvedSymbol;
77181
77240
  if (symbol) {
77182
77241
  return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
@@ -77192,7 +77251,7 @@ var ts;
77192
77251
  }
77193
77252
  ts.forEach(node.typeArguments, checkSourceElement);
77194
77253
  var type = getTypeFromTypeReference(node);
77195
- if (type !== errorType) {
77254
+ if (!isErrorType(type)) {
77196
77255
  if (node.typeArguments && produceDiagnostics) {
77197
77256
  var typeParameters = getTypeParametersForTypeReference(node);
77198
77257
  if (typeParameters) {
@@ -78018,7 +78077,7 @@ var ts;
78018
78077
  //
78019
78078
  var returnType = getTypeFromTypeNode(returnTypeNode);
78020
78079
  if (languageVersion >= 2 /* ES2015 */) {
78021
- if (returnType === errorType) {
78080
+ if (isErrorType(returnType)) {
78022
78081
  return;
78023
78082
  }
78024
78083
  var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
@@ -78032,7 +78091,7 @@ var ts;
78032
78091
  else {
78033
78092
  // Always mark the type node as referenced if it points to a value
78034
78093
  markTypeNodeAsReferenced(returnTypeNode);
78035
- if (returnType === errorType) {
78094
+ if (isErrorType(returnType)) {
78036
78095
  return;
78037
78096
  }
78038
78097
  var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
@@ -78042,7 +78101,7 @@ var ts;
78042
78101
  }
78043
78102
  var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
78044
78103
  var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
78045
- if (promiseConstructorType === errorType) {
78104
+ if (isErrorType(promiseConstructorType)) {
78046
78105
  if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
78047
78106
  error(returnTypeNode, ts.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);
78048
78107
  }
@@ -79094,7 +79153,7 @@ var ts;
79094
79153
  // Node is a secondary declaration, check that type is identical to primary declaration and check that
79095
79154
  // initializer is consistent with type associated with the node
79096
79155
  var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
79097
- if (type !== errorType && declarationType !== errorType &&
79156
+ if (!isErrorType(type) && !isErrorType(declarationType) &&
79098
79157
  !isTypeIdenticalTo(type, declarationType) &&
79099
79158
  !(symbol.flags & 67108864 /* Assignment */)) {
79100
79159
  errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
@@ -80592,7 +80651,7 @@ var ts;
80592
80651
  checkTypeReferenceNode(typeRefNode);
80593
80652
  if (produceDiagnostics) {
80594
80653
  var t = getReducedType(getTypeFromTypeNode(typeRefNode));
80595
- if (t !== errorType) {
80654
+ if (!isErrorType(t)) {
80596
80655
  if (isValidBaseType(t)) {
80597
80656
  var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
80598
80657
  ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
@@ -82632,7 +82691,8 @@ var ts;
82632
82691
  }
82633
82692
  else if (isTypeReferenceIdentifier(name)) {
82634
82693
  var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
82635
- return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
82694
+ var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
82695
+ return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
82636
82696
  }
82637
82697
  if (name.parent.kind === 176 /* TypePredicate */) {
82638
82698
  return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
@@ -82859,7 +82919,7 @@ var ts;
82859
82919
  var symbol = getSymbolAtLocation(node);
82860
82920
  if (symbol) {
82861
82921
  var declaredType = getDeclaredTypeOfSymbol(symbol);
82862
- return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
82922
+ return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
82863
82923
  }
82864
82924
  }
82865
82925
  if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
@@ -83357,7 +83417,7 @@ var ts;
83357
83417
  return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
83358
83418
  }
83359
83419
  var type = getDeclaredTypeOfSymbol(typeSymbol);
83360
- if (type === errorType) {
83420
+ if (isErrorType(type)) {
83361
83421
  return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
83362
83422
  }
83363
83423
  else if (type.flags & 3 /* AnyOrUnknown */) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.5.0-dev.20210923",
5
+ "version": "4.5.0-dev.20210924",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [