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.
- package/lib/lib.es5.d.ts +1 -1
- package/lib/tsc.js +64 -47
- package/lib/tsserver.js +81 -62
- package/lib/tsserverlibrary.js +81 -62
- package/lib/typescript.js +81 -62
- package/lib/typescriptServices.js +81 -62
- package/lib/typingsInstaller.js +81 -62
- package/package.json +2 -2
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
-
//
|
|
63819
|
-
//
|
|
63820
|
-
//
|
|
63821
|
-
var broadestEquivalentId = id.
|
|
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
|
-
|
|
65336
|
-
|
|
65337
|
-
|
|
65338
|
-
|
|
65339
|
-
|
|
65340
|
-
|
|
65341
|
-
|
|
65342
|
-
|
|
65343
|
-
if (
|
|
65344
|
-
|
|
65345
|
-
|
|
65346
|
-
|
|
65347
|
-
|
|
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
|
-
|
|
65372
|
-
|
|
65373
|
-
|
|
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
|
|
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
|
|
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
|
|
65428
|
-
// the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
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
|
|
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
|
-
//
|
|
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 =
|
|
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
|
-
|
|
65441
|
-
|
|
65442
|
-
|
|
65443
|
-
|
|
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
|
package/lib/typescript.js
CHANGED
|
@@ -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.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
-
//
|
|
63819
|
-
//
|
|
63820
|
-
//
|
|
63821
|
-
var broadestEquivalentId = id.
|
|
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
|
-
|
|
65336
|
-
|
|
65337
|
-
|
|
65338
|
-
|
|
65339
|
-
|
|
65340
|
-
|
|
65341
|
-
|
|
65342
|
-
|
|
65343
|
-
if (
|
|
65344
|
-
|
|
65345
|
-
|
|
65346
|
-
|
|
65347
|
-
|
|
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
|
-
|
|
65372
|
-
|
|
65373
|
-
|
|
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
|
|
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
|
|
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
|
|
65428
|
-
// the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
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
|
|
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
|
-
//
|
|
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 =
|
|
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
|
-
|
|
65441
|
-
|
|
65442
|
-
|
|
65443
|
-
|
|
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
|