typescript 4.5.2 → 4.5.3

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = "4.5.2";
297
+ ts.version = "4.5.3";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -41653,7 +41653,10 @@ var ts;
41653
41653
  }
41654
41654
  }
41655
41655
  var failedLookupLocations = [];
41656
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
41656
+ var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41657
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41658
+ NodeResolutionFeatures.None;
41659
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41657
41660
  var resolved = primaryLookup();
41658
41661
  var primary = true;
41659
41662
  if (!resolved) {
@@ -42328,13 +42331,15 @@ var ts;
42328
42331
  // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
42329
42332
  NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
42330
42333
  NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
42334
+ NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
42335
+ NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
42331
42336
  NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
42332
42337
  })(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
42333
42338
  function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42334
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42339
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42335
42340
  }
42336
42341
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42337
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42342
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42338
42343
  }
42339
42344
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42340
42345
  var containingDirectory = ts.getDirectoryPath(containingFile);
@@ -48297,11 +48302,12 @@ var ts;
48297
48302
  *
48298
48303
  * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
48299
48304
  */
48300
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
48305
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
48301
48306
  if (excludeGlobals === void 0) { excludeGlobals = false; }
48302
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol);
48307
+ if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
48308
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
48303
48309
  }
48304
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
48310
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
48305
48311
  var _a, _b, _c;
48306
48312
  var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
48307
48313
  var result;
@@ -48618,7 +48624,7 @@ var ts;
48618
48624
  }
48619
48625
  }
48620
48626
  if (!result) {
48621
- if (nameNotFoundMessage) {
48627
+ if (nameNotFoundMessage && produceDiagnostics) {
48622
48628
  if (!errorLocation ||
48623
48629
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
48624
48630
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
@@ -48628,7 +48634,7 @@ var ts;
48628
48634
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
48629
48635
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
48630
48636
  var suggestion = void 0;
48631
- if (suggestionCount < maximumSuggestionCount) {
48637
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
48632
48638
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
48633
48639
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
48634
48640
  if (isGlobalScopeAugmentationDeclaration) {
@@ -48664,7 +48670,7 @@ var ts;
48664
48670
  return undefined;
48665
48671
  }
48666
48672
  // Perform extra checks only if error reporting was requested
48667
- if (nameNotFoundMessage) {
48673
+ if (nameNotFoundMessage && produceDiagnostics) {
48668
48674
  if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
48669
48675
  // We have a match, but the reference occurred within a property initializer and the identifier also binds
48670
48676
  // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
@@ -59069,7 +59075,7 @@ var ts;
59069
59075
  }
59070
59076
  function getGlobalSymbol(name, meaning, diagnostic) {
59071
59077
  // Don't track references for global symbols anyway, so value if `isReference` is arbitrary
59072
- return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
59078
+ return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
59073
59079
  }
59074
59080
  function getGlobalType(name, arity, reportErrors) {
59075
59081
  var symbol = getGlobalTypeSymbol(name, reportErrors);
@@ -62939,7 +62945,7 @@ var ts;
62939
62945
  return true;
62940
62946
  }
62941
62947
  if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
62942
- var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
62948
+ var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
62943
62949
  if (related !== undefined) {
62944
62950
  return !!(related & 1 /* Succeeded */);
62945
62951
  }
@@ -63788,7 +63794,8 @@ var ts;
63788
63794
  if (overflow) {
63789
63795
  return 0 /* False */;
63790
63796
  }
63791
- var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0), relation);
63797
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
63798
+ var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
63792
63799
  var entry = relation.get(id);
63793
63800
  if (entry !== undefined) {
63794
63801
  if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
@@ -63815,16 +63822,13 @@ var ts;
63815
63822
  targetStack = [];
63816
63823
  }
63817
63824
  else {
63818
- // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids
63819
- // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus
63820
- // prevent finding matches- but it should hit up the common cases
63821
- var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) {
63822
- var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
63823
- return "=".concat(index);
63824
- }); }).join(",");
63825
+ // A key that starts with "*" is an indication that we have type references that reference constrained
63826
+ // type parameters. For such keys we also check against the key we would have gotten if all type parameters
63827
+ // were unconstrained.
63828
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
63825
63829
  for (var i = 0; i < maybeCount; i++) {
63826
63830
  // If source and target are already being compared, consider them related with assumptions
63827
- if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
63831
+ if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
63828
63832
  return 3 /* Maybe */;
63829
63833
  }
63830
63834
  }
@@ -65331,48 +65335,56 @@ var ts;
65331
65335
  function isTypeReferenceWithGenericArguments(type) {
65332
65336
  return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
65333
65337
  }
65334
- /**
65335
- * getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65336
- * where A.id=111 and number.id=12
65337
- */
65338
- function getTypeReferenceId(type, typeParameters, depth) {
65339
- if (depth === void 0) { depth = 0; }
65340
- var result = "" + type.target.id;
65341
- for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65342
- var t = _a[_i];
65343
- if (isUnconstrainedTypeParameter(t)) {
65344
- var index = typeParameters.indexOf(t);
65345
- if (index < 0) {
65346
- index = typeParameters.length;
65347
- typeParameters.push(t);
65338
+ function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
65339
+ var typeParameters = [];
65340
+ var constraintMarker = "";
65341
+ var sourceId = getTypeReferenceId(source, 0);
65342
+ var targetId = getTypeReferenceId(target, 0);
65343
+ return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix);
65344
+ // getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65345
+ // where A.id=111 and number.id=12
65346
+ function getTypeReferenceId(type, depth) {
65347
+ if (depth === void 0) { depth = 0; }
65348
+ var result = "" + type.target.id;
65349
+ for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65350
+ var t = _a[_i];
65351
+ if (t.flags & 262144 /* TypeParameter */) {
65352
+ if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
65353
+ var index = typeParameters.indexOf(t);
65354
+ if (index < 0) {
65355
+ index = typeParameters.length;
65356
+ typeParameters.push(t);
65357
+ }
65358
+ result += "=" + index;
65359
+ continue;
65360
+ }
65361
+ // We mark type references that reference constrained type parameters such that we know to obtain
65362
+ // and look for a "broadest equivalent key" in the cache.
65363
+ constraintMarker = "*";
65364
+ }
65365
+ else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65366
+ result += "<" + getTypeReferenceId(t, depth + 1) + ">";
65367
+ continue;
65348
65368
  }
65349
- result += "=" + index;
65350
- }
65351
- else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65352
- result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
65353
- }
65354
- else {
65355
65369
  result += "-" + t.id;
65356
65370
  }
65371
+ return result;
65357
65372
  }
65358
- return result;
65359
65373
  }
65360
65374
  /**
65361
65375
  * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
65362
65376
  * For other cases, the types ids are used.
65363
65377
  */
65364
- function getRelationKey(source, target, intersectionState, relation) {
65378
+ function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
65365
65379
  if (relation === identityRelation && source.id > target.id) {
65366
65380
  var temp = source;
65367
65381
  source = target;
65368
65382
  target = temp;
65369
65383
  }
65370
65384
  var postFix = intersectionState ? ":" + intersectionState : "";
65371
- if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
65372
- var typeParameters = [];
65373
- return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
65374
- }
65375
- return source.id + "," + target.id + postFix;
65385
+ return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
65386
+ getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
65387
+ "".concat(source.id, ",").concat(target.id).concat(postFix);
65376
65388
  }
65377
65389
  // Invoke the callback for each underlying property symbol of the given symbol and return the first
65378
65390
  // value that isn't undefined.
@@ -65420,28 +65432,35 @@ var ts;
65420
65432
  !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
65421
65433
  }
65422
65434
  // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
65423
- // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65435
+ // for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65424
65436
  // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
65425
- // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5
65437
+ // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
65426
65438
  // levels, but unequal at some level beyond that.
65427
- // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially
65428
- // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives
65429
- // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65430
- // It also detects when a recursive type reference has expanded 5 or more times, eg, if the true branch of
65439
+ // In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
65440
+ // essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
65441
+ // false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65442
+ // It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
65431
65443
  // `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
65432
- // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
65433
- // in such cases we need to terminate the expansion, and we do so here.
65444
+ // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
65445
+ // to terminate the expansion, and we do so here.
65434
65446
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
65435
- if (maxDepth === void 0) { maxDepth = 5; }
65447
+ if (maxDepth === void 0) { maxDepth = 3; }
65436
65448
  if (depth >= maxDepth) {
65437
65449
  var identity_1 = getRecursionIdentity(type);
65438
65450
  var count = 0;
65451
+ var lastTypeId = 0;
65439
65452
  for (var i = 0; i < depth; i++) {
65440
- if (getRecursionIdentity(stack[i]) === identity_1) {
65441
- count++;
65442
- if (count >= maxDepth) {
65443
- return true;
65453
+ var t = stack[i];
65454
+ if (getRecursionIdentity(t) === identity_1) {
65455
+ // We only count occurrences with a higher type id than the previous occurrence, since higher
65456
+ // type ids are an indicator of newer instantiations caused by recursion.
65457
+ if (t.id >= lastTypeId) {
65458
+ count++;
65459
+ if (count >= maxDepth) {
65460
+ return true;
65461
+ }
65444
65462
  }
65463
+ lastTypeId = t.id;
65445
65464
  }
65446
65465
  }
65447
65466
  }
@@ -73031,7 +73050,7 @@ var ts;
73031
73050
  }
73032
73051
  function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
73033
73052
  ts.Debug.assert(outerName !== undefined, "outername should always be defined");
73034
- var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, function (symbols, name, meaning) {
73053
+ var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
73035
73054
  ts.Debug.assertEqual(outerName, name, "name should equal outerName");
73036
73055
  var symbol = getSymbol(symbols, name, meaning);
73037
73056
  // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
@@ -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 = "4.5.2";
92
+ ts.version = "4.5.3";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -41448,7 +41448,10 @@ var ts;
41448
41448
  }
41449
41449
  }
41450
41450
  var failedLookupLocations = [];
41451
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
41451
+ var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41452
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41453
+ NodeResolutionFeatures.None;
41454
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41452
41455
  var resolved = primaryLookup();
41453
41456
  var primary = true;
41454
41457
  if (!resolved) {
@@ -42123,13 +42126,15 @@ var ts;
42123
42126
  // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
42124
42127
  NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
42125
42128
  NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
42129
+ NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
42130
+ NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
42126
42131
  NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
42127
42132
  })(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
42128
42133
  function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42129
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42134
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42130
42135
  }
42131
42136
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42132
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42137
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42133
42138
  }
42134
42139
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42135
42140
  var containingDirectory = ts.getDirectoryPath(containingFile);
@@ -48092,11 +48097,12 @@ var ts;
48092
48097
  *
48093
48098
  * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
48094
48099
  */
48095
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
48100
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
48096
48101
  if (excludeGlobals === void 0) { excludeGlobals = false; }
48097
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol);
48102
+ if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
48103
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
48098
48104
  }
48099
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
48105
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
48100
48106
  var _a, _b, _c;
48101
48107
  var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
48102
48108
  var result;
@@ -48413,7 +48419,7 @@ var ts;
48413
48419
  }
48414
48420
  }
48415
48421
  if (!result) {
48416
- if (nameNotFoundMessage) {
48422
+ if (nameNotFoundMessage && produceDiagnostics) {
48417
48423
  if (!errorLocation ||
48418
48424
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
48419
48425
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
@@ -48423,7 +48429,7 @@ var ts;
48423
48429
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
48424
48430
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
48425
48431
  var suggestion = void 0;
48426
- if (suggestionCount < maximumSuggestionCount) {
48432
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
48427
48433
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
48428
48434
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
48429
48435
  if (isGlobalScopeAugmentationDeclaration) {
@@ -48459,7 +48465,7 @@ var ts;
48459
48465
  return undefined;
48460
48466
  }
48461
48467
  // Perform extra checks only if error reporting was requested
48462
- if (nameNotFoundMessage) {
48468
+ if (nameNotFoundMessage && produceDiagnostics) {
48463
48469
  if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
48464
48470
  // We have a match, but the reference occurred within a property initializer and the identifier also binds
48465
48471
  // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
@@ -58864,7 +58870,7 @@ var ts;
58864
58870
  }
58865
58871
  function getGlobalSymbol(name, meaning, diagnostic) {
58866
58872
  // Don't track references for global symbols anyway, so value if `isReference` is arbitrary
58867
- return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
58873
+ return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
58868
58874
  }
58869
58875
  function getGlobalType(name, arity, reportErrors) {
58870
58876
  var symbol = getGlobalTypeSymbol(name, reportErrors);
@@ -62734,7 +62740,7 @@ var ts;
62734
62740
  return true;
62735
62741
  }
62736
62742
  if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
62737
- var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
62743
+ var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
62738
62744
  if (related !== undefined) {
62739
62745
  return !!(related & 1 /* Succeeded */);
62740
62746
  }
@@ -63583,7 +63589,8 @@ var ts;
63583
63589
  if (overflow) {
63584
63590
  return 0 /* False */;
63585
63591
  }
63586
- var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0), relation);
63592
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
63593
+ var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
63587
63594
  var entry = relation.get(id);
63588
63595
  if (entry !== undefined) {
63589
63596
  if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
@@ -63610,16 +63617,13 @@ var ts;
63610
63617
  targetStack = [];
63611
63618
  }
63612
63619
  else {
63613
- // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids
63614
- // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus
63615
- // prevent finding matches- but it should hit up the common cases
63616
- var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) {
63617
- var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
63618
- return "=".concat(index);
63619
- }); }).join(",");
63620
+ // A key that starts with "*" is an indication that we have type references that reference constrained
63621
+ // type parameters. For such keys we also check against the key we would have gotten if all type parameters
63622
+ // were unconstrained.
63623
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
63620
63624
  for (var i = 0; i < maybeCount; i++) {
63621
63625
  // If source and target are already being compared, consider them related with assumptions
63622
- if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
63626
+ if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
63623
63627
  return 3 /* Maybe */;
63624
63628
  }
63625
63629
  }
@@ -65126,48 +65130,56 @@ var ts;
65126
65130
  function isTypeReferenceWithGenericArguments(type) {
65127
65131
  return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
65128
65132
  }
65129
- /**
65130
- * getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65131
- * where A.id=111 and number.id=12
65132
- */
65133
- function getTypeReferenceId(type, typeParameters, depth) {
65134
- if (depth === void 0) { depth = 0; }
65135
- var result = "" + type.target.id;
65136
- for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65137
- var t = _a[_i];
65138
- if (isUnconstrainedTypeParameter(t)) {
65139
- var index = typeParameters.indexOf(t);
65140
- if (index < 0) {
65141
- index = typeParameters.length;
65142
- typeParameters.push(t);
65133
+ function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
65134
+ var typeParameters = [];
65135
+ var constraintMarker = "";
65136
+ var sourceId = getTypeReferenceId(source, 0);
65137
+ var targetId = getTypeReferenceId(target, 0);
65138
+ return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix);
65139
+ // getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65140
+ // where A.id=111 and number.id=12
65141
+ function getTypeReferenceId(type, depth) {
65142
+ if (depth === void 0) { depth = 0; }
65143
+ var result = "" + type.target.id;
65144
+ for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65145
+ var t = _a[_i];
65146
+ if (t.flags & 262144 /* TypeParameter */) {
65147
+ if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
65148
+ var index = typeParameters.indexOf(t);
65149
+ if (index < 0) {
65150
+ index = typeParameters.length;
65151
+ typeParameters.push(t);
65152
+ }
65153
+ result += "=" + index;
65154
+ continue;
65155
+ }
65156
+ // We mark type references that reference constrained type parameters such that we know to obtain
65157
+ // and look for a "broadest equivalent key" in the cache.
65158
+ constraintMarker = "*";
65159
+ }
65160
+ else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65161
+ result += "<" + getTypeReferenceId(t, depth + 1) + ">";
65162
+ continue;
65143
65163
  }
65144
- result += "=" + index;
65145
- }
65146
- else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65147
- result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
65148
- }
65149
- else {
65150
65164
  result += "-" + t.id;
65151
65165
  }
65166
+ return result;
65152
65167
  }
65153
- return result;
65154
65168
  }
65155
65169
  /**
65156
65170
  * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
65157
65171
  * For other cases, the types ids are used.
65158
65172
  */
65159
- function getRelationKey(source, target, intersectionState, relation) {
65173
+ function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
65160
65174
  if (relation === identityRelation && source.id > target.id) {
65161
65175
  var temp = source;
65162
65176
  source = target;
65163
65177
  target = temp;
65164
65178
  }
65165
65179
  var postFix = intersectionState ? ":" + intersectionState : "";
65166
- if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
65167
- var typeParameters = [];
65168
- return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
65169
- }
65170
- return source.id + "," + target.id + postFix;
65180
+ return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
65181
+ getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
65182
+ "".concat(source.id, ",").concat(target.id).concat(postFix);
65171
65183
  }
65172
65184
  // Invoke the callback for each underlying property symbol of the given symbol and return the first
65173
65185
  // value that isn't undefined.
@@ -65215,28 +65227,35 @@ var ts;
65215
65227
  !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
65216
65228
  }
65217
65229
  // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
65218
- // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65230
+ // for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65219
65231
  // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
65220
- // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5
65232
+ // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
65221
65233
  // levels, but unequal at some level beyond that.
65222
- // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially
65223
- // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives
65224
- // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65225
- // It also detects when a recursive type reference has expanded 5 or more times, eg, if the true branch of
65234
+ // In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
65235
+ // essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
65236
+ // false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65237
+ // It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
65226
65238
  // `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
65227
- // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
65228
- // in such cases we need to terminate the expansion, and we do so here.
65239
+ // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
65240
+ // to terminate the expansion, and we do so here.
65229
65241
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
65230
- if (maxDepth === void 0) { maxDepth = 5; }
65242
+ if (maxDepth === void 0) { maxDepth = 3; }
65231
65243
  if (depth >= maxDepth) {
65232
65244
  var identity_1 = getRecursionIdentity(type);
65233
65245
  var count = 0;
65246
+ var lastTypeId = 0;
65234
65247
  for (var i = 0; i < depth; i++) {
65235
- if (getRecursionIdentity(stack[i]) === identity_1) {
65236
- count++;
65237
- if (count >= maxDepth) {
65238
- return true;
65248
+ var t = stack[i];
65249
+ if (getRecursionIdentity(t) === identity_1) {
65250
+ // We only count occurrences with a higher type id than the previous occurrence, since higher
65251
+ // type ids are an indicator of newer instantiations caused by recursion.
65252
+ if (t.id >= lastTypeId) {
65253
+ count++;
65254
+ if (count >= maxDepth) {
65255
+ return true;
65256
+ }
65239
65257
  }
65258
+ lastTypeId = t.id;
65240
65259
  }
65241
65260
  }
65242
65261
  }
@@ -72826,7 +72845,7 @@ var ts;
72826
72845
  }
72827
72846
  function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
72828
72847
  ts.Debug.assert(outerName !== undefined, "outername should always be defined");
72829
- var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, function (symbols, name, meaning) {
72848
+ var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
72830
72849
  ts.Debug.assertEqual(outerName, name, "name should equal outerName");
72831
72850
  var symbol = getSymbol(symbols, name, meaning);
72832
72851
  // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
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.2",
5
+ "version": "4.5.3",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -61,7 +61,7 @@
61
61
  "browser-resolve": "^1.11.2",
62
62
  "browserify": "latest",
63
63
  "chai": "latest",
64
- "chalk": "latest",
64
+ "chalk": "^4.1.2",
65
65
  "convert-source-map": "latest",
66
66
  "del": "5.1.0",
67
67
  "diff": "^4.0.2",