typescript 4.8.0-dev.20220801 → 4.8.0-dev.20220804
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.es2015.promise.d.ts +9 -4
- package/lib/lib.es5.d.ts +2 -2
- package/lib/tsc.js +433 -226
- package/lib/tsserver.js +576 -294
- package/lib/tsserverlibrary.d.ts +16 -10
- package/lib/tsserverlibrary.js +576 -294
- package/lib/typescript.d.ts +16 -10
- package/lib/typescript.js +571 -289
- package/lib/typescriptServices.d.ts +16 -10
- package/lib/typescriptServices.js +571 -289
- package/lib/typingsInstaller.js +527 -256
- package/package.json +4 -1
package/lib/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220804";
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -8571,6 +8571,10 @@ var ts;
|
|
|
8571
8571
|
resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
|
|
8572
8572
|
Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."),
|
|
8573
8573
|
Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"),
|
|
8574
|
+
File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""),
|
|
8575
|
+
File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""),
|
|
8576
|
+
File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""),
|
|
8577
|
+
File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"),
|
|
8574
8578
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8575
8579
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8576
8580
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -21874,7 +21878,7 @@ var ts;
|
|
|
21874
21878
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
21875
21879
|
* property or element access.
|
|
21876
21880
|
*/
|
|
21877
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
21881
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
21878
21882
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
21879
21883
|
// to parenthesize the expression before a dot. The known exception is:
|
|
21880
21884
|
//
|
|
@@ -21883,7 +21887,8 @@ var ts;
|
|
|
21883
21887
|
//
|
|
21884
21888
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
21885
21889
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
21886
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21890
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21891
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
21887
21892
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
21888
21893
|
return expression;
|
|
21889
21894
|
}
|
|
@@ -23290,7 +23295,7 @@ var ts;
|
|
|
23290
23295
|
// @api
|
|
23291
23296
|
function createDecorator(expression) {
|
|
23292
23297
|
var node = createBaseNode(165 /* Decorator */);
|
|
23293
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23298
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23294
23299
|
node.transformFlags |=
|
|
23295
23300
|
propagateChildFlags(node.expression) |
|
|
23296
23301
|
1 /* ContainsTypeScript */ |
|
|
@@ -24091,7 +24096,7 @@ var ts;
|
|
|
24091
24096
|
// @api
|
|
24092
24097
|
function createPropertyAccessExpression(expression, name) {
|
|
24093
24098
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24094
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24099
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24095
24100
|
node.name = asName(name);
|
|
24096
24101
|
node.transformFlags =
|
|
24097
24102
|
propagateChildFlags(node.expression) |
|
|
@@ -24121,7 +24126,7 @@ var ts;
|
|
|
24121
24126
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24122
24127
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24123
24128
|
node.flags |= 32 /* OptionalChain */;
|
|
24124
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24129
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24125
24130
|
node.questionDotToken = questionDotToken;
|
|
24126
24131
|
node.name = asName(name);
|
|
24127
24132
|
node.transformFlags |=
|
|
@@ -24147,7 +24152,7 @@ var ts;
|
|
|
24147
24152
|
// @api
|
|
24148
24153
|
function createElementAccessExpression(expression, index) {
|
|
24149
24154
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24150
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24155
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24151
24156
|
node.argumentExpression = asExpression(index);
|
|
24152
24157
|
node.transformFlags |=
|
|
24153
24158
|
propagateChildFlags(node.expression) |
|
|
@@ -24175,7 +24180,7 @@ var ts;
|
|
|
24175
24180
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24176
24181
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24177
24182
|
node.flags |= 32 /* OptionalChain */;
|
|
24178
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24183
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24179
24184
|
node.questionDotToken = questionDotToken;
|
|
24180
24185
|
node.argumentExpression = asExpression(index);
|
|
24181
24186
|
node.transformFlags |=
|
|
@@ -24199,7 +24204,7 @@ var ts;
|
|
|
24199
24204
|
// @api
|
|
24200
24205
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24201
24206
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24202
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24207
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24203
24208
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24204
24209
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24205
24210
|
node.transformFlags |=
|
|
@@ -24232,7 +24237,7 @@ var ts;
|
|
|
24232
24237
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24233
24238
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24234
24239
|
node.flags |= 32 /* OptionalChain */;
|
|
24235
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24240
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24236
24241
|
node.questionDotToken = questionDotToken;
|
|
24237
24242
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24238
24243
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24287,7 +24292,7 @@ var ts;
|
|
|
24287
24292
|
// @api
|
|
24288
24293
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24289
24294
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24290
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24295
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24291
24296
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24292
24297
|
node.template = template;
|
|
24293
24298
|
node.transformFlags |=
|
|
@@ -24725,7 +24730,7 @@ var ts;
|
|
|
24725
24730
|
// @api
|
|
24726
24731
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24727
24732
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24728
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24733
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24729
24734
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24730
24735
|
node.transformFlags |=
|
|
24731
24736
|
propagateChildFlags(node.expression) |
|
|
@@ -24761,7 +24766,7 @@ var ts;
|
|
|
24761
24766
|
// @api
|
|
24762
24767
|
function createNonNullExpression(expression) {
|
|
24763
24768
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24764
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24769
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24765
24770
|
node.transformFlags |=
|
|
24766
24771
|
propagateChildFlags(node.expression) |
|
|
24767
24772
|
1 /* ContainsTypeScript */;
|
|
@@ -24780,7 +24785,7 @@ var ts;
|
|
|
24780
24785
|
function createNonNullChain(expression) {
|
|
24781
24786
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24782
24787
|
node.flags |= 32 /* OptionalChain */;
|
|
24783
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24788
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24784
24789
|
node.transformFlags |=
|
|
24785
24790
|
propagateChildFlags(node.expression) |
|
|
24786
24791
|
1 /* ContainsTypeScript */;
|
|
@@ -26984,7 +26989,7 @@ var ts;
|
|
|
26984
26989
|
}
|
|
26985
26990
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
26986
26991
|
thisArg = createVoidZero();
|
|
26987
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
26992
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
26988
26993
|
}
|
|
26989
26994
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
26990
26995
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -27013,7 +27018,7 @@ var ts;
|
|
|
27013
27018
|
else {
|
|
27014
27019
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
27015
27020
|
thisArg = createVoidZero();
|
|
27016
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27021
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27017
27022
|
}
|
|
27018
27023
|
return { target: target, thisArg: thisArg };
|
|
27019
27024
|
}
|
|
@@ -43248,7 +43253,7 @@ var ts;
|
|
|
43248
43253
|
ts.createCacheWithRedirects = createCacheWithRedirects;
|
|
43249
43254
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
43250
43255
|
var cache;
|
|
43251
|
-
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
|
|
43256
|
+
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
|
|
43252
43257
|
function getPackageJsonInfo(packageJsonPath) {
|
|
43253
43258
|
return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
|
|
43254
43259
|
}
|
|
@@ -43262,6 +43267,9 @@ var ts;
|
|
|
43262
43267
|
var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
|
|
43263
43268
|
return iter ? ts.arrayFrom(iter) : [];
|
|
43264
43269
|
}
|
|
43270
|
+
function getInternalMap() {
|
|
43271
|
+
return cache;
|
|
43272
|
+
}
|
|
43265
43273
|
}
|
|
43266
43274
|
function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
|
|
43267
43275
|
var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
@@ -43365,15 +43373,18 @@ var ts;
|
|
|
43365
43373
|
}
|
|
43366
43374
|
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
43367
43375
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
43368
|
-
var
|
|
43376
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43369
43377
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
43370
43378
|
var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
43371
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43379
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43372
43380
|
function clear() {
|
|
43373
|
-
|
|
43374
|
-
moduleNameToDirectoryMap.clear();
|
|
43381
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43375
43382
|
packageJsonInfoCache.clear();
|
|
43376
43383
|
}
|
|
43384
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43385
|
+
perDirectoryResolutionCache.clear();
|
|
43386
|
+
moduleNameToDirectoryMap.clear();
|
|
43387
|
+
}
|
|
43377
43388
|
function update(options) {
|
|
43378
43389
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
43379
43390
|
}
|
|
@@ -43449,13 +43460,16 @@ var ts;
|
|
|
43449
43460
|
}
|
|
43450
43461
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
43451
43462
|
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
|
|
43452
|
-
var
|
|
43463
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43453
43464
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
43454
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43465
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43455
43466
|
function clear() {
|
|
43456
|
-
|
|
43467
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43457
43468
|
packageJsonInfoCache.clear();
|
|
43458
43469
|
}
|
|
43470
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43471
|
+
perDirectoryResolutionCache.clear();
|
|
43472
|
+
}
|
|
43459
43473
|
}
|
|
43460
43474
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
43461
43475
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
@@ -51243,10 +51257,6 @@ var ts;
|
|
|
51243
51257
|
checkExpressionCached(expression);
|
|
51244
51258
|
return getNodeLinks(expression).resolvedSymbol;
|
|
51245
51259
|
}
|
|
51246
|
-
function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
|
|
51247
|
-
var expression = node.initializer;
|
|
51248
|
-
return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
|
|
51249
|
-
}
|
|
51250
51260
|
function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
|
|
51251
51261
|
if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
|
|
51252
51262
|
return undefined;
|
|
@@ -51278,7 +51288,7 @@ var ts;
|
|
|
51278
51288
|
case 297 /* ShorthandPropertyAssignment */:
|
|
51279
51289
|
return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
|
|
51280
51290
|
case 296 /* PropertyAssignment */:
|
|
51281
|
-
return
|
|
51291
|
+
return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
|
|
51282
51292
|
case 207 /* ElementAccessExpression */:
|
|
51283
51293
|
case 206 /* PropertyAccessExpression */:
|
|
51284
51294
|
return getTargetOfAccessExpression(node, dontRecursivelyResolve);
|
|
@@ -56803,7 +56813,7 @@ var ts;
|
|
|
56803
56813
|
(resolvedSymbol || symbol).exports.forEach(function (s, name) {
|
|
56804
56814
|
var _a;
|
|
56805
56815
|
var exportedMember = members_4.get(name);
|
|
56806
|
-
if (exportedMember && exportedMember !== s) {
|
|
56816
|
+
if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
|
|
56807
56817
|
if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
|
|
56808
56818
|
// If the member has an additional value-like declaration, union the types from the two declarations,
|
|
56809
56819
|
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
|
|
@@ -63295,6 +63305,7 @@ var ts;
|
|
|
63295
63305
|
}
|
|
63296
63306
|
}
|
|
63297
63307
|
function getTypeFromImportTypeNode(node) {
|
|
63308
|
+
var _a;
|
|
63298
63309
|
var links = getNodeLinks(node);
|
|
63299
63310
|
if (!links.resolvedType) {
|
|
63300
63311
|
if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
|
|
@@ -63314,6 +63325,7 @@ var ts;
|
|
|
63314
63325
|
links.resolvedSymbol = unknownSymbol;
|
|
63315
63326
|
return links.resolvedType = errorType;
|
|
63316
63327
|
}
|
|
63328
|
+
var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
|
|
63317
63329
|
var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
|
|
63318
63330
|
if (!ts.nodeIsMissing(node.qualifier)) {
|
|
63319
63331
|
var nameStack = getIdentifierChain(node.qualifier);
|
|
@@ -63325,9 +63337,11 @@ var ts;
|
|
|
63325
63337
|
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
|
|
63326
63338
|
// the `exports` lookup process that only looks up namespace members which is used for most type references
|
|
63327
63339
|
var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
|
|
63328
|
-
var
|
|
63340
|
+
var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
|
|
63329
63341
|
? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
|
|
63330
|
-
:
|
|
63342
|
+
: undefined;
|
|
63343
|
+
var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
|
|
63344
|
+
var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
|
|
63331
63345
|
if (!next) {
|
|
63332
63346
|
error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
|
|
63333
63347
|
return links.resolvedType = errorType;
|
|
@@ -66185,6 +66199,26 @@ var ts;
|
|
|
66185
66199
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66186
66200
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66187
66201
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66202
|
+
if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
|
|
66203
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66204
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
66205
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66206
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66207
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66208
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66209
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66210
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66211
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
66212
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66213
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66214
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66215
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66216
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66217
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66218
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66219
|
+
result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66220
|
+
}
|
|
66221
|
+
}
|
|
66188
66222
|
if (result) {
|
|
66189
66223
|
resetErrorInfo(saveErrorInfo);
|
|
66190
66224
|
}
|
|
@@ -66242,28 +66276,6 @@ var ts;
|
|
|
66242
66276
|
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
66243
66277
|
return result;
|
|
66244
66278
|
}
|
|
66245
|
-
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
66246
|
-
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66247
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
66248
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66249
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66250
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66251
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66252
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66253
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66254
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
66255
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66256
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66257
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66258
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66259
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66260
|
-
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66261
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66262
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66263
|
-
return result;
|
|
66264
|
-
}
|
|
66265
|
-
}
|
|
66266
|
-
}
|
|
66267
66279
|
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
66268
66280
|
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
66269
66281
|
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
@@ -82117,9 +82129,11 @@ var ts;
|
|
|
82117
82129
|
// We only need `Awaited<T>` if `T` contains possibly non-primitive types.
|
|
82118
82130
|
if (isGenericObjectType(type)) {
|
|
82119
82131
|
var baseConstraint = getBaseConstraintOfType(type);
|
|
82120
|
-
// We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82132
|
+
// We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82121
82133
|
// or is promise-like.
|
|
82122
|
-
if (
|
|
82134
|
+
if (baseConstraint ?
|
|
82135
|
+
baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
|
|
82136
|
+
maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
|
|
82123
82137
|
return true;
|
|
82124
82138
|
}
|
|
82125
82139
|
}
|
|
@@ -83996,17 +84010,28 @@ var ts;
|
|
|
83996
84010
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
83997
84011
|
*/
|
|
83998
84012
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84013
|
+
var _a, _b;
|
|
83999
84014
|
if (isTypeAny(type)) {
|
|
84000
84015
|
return anyIterationTypes;
|
|
84001
84016
|
}
|
|
84002
84017
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
84003
|
-
var
|
|
84018
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84019
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
84004
84020
|
if (iterationTypes_1 === noIterationTypes) {
|
|
84005
84021
|
if (errorNode) {
|
|
84006
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84022
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84023
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84024
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84025
|
+
}
|
|
84007
84026
|
}
|
|
84008
84027
|
return undefined;
|
|
84009
84028
|
}
|
|
84029
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84030
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84031
|
+
var diag = _c[_i];
|
|
84032
|
+
diagnostics.add(diag);
|
|
84033
|
+
}
|
|
84034
|
+
}
|
|
84010
84035
|
return iterationTypes_1;
|
|
84011
84036
|
}
|
|
84012
84037
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84014,19 +84039,27 @@ var ts;
|
|
|
84014
84039
|
if (cachedTypes)
|
|
84015
84040
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84016
84041
|
var allIterationTypes;
|
|
84017
|
-
for (var
|
|
84018
|
-
var constituent =
|
|
84019
|
-
var
|
|
84042
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84043
|
+
var constituent = _e[_d];
|
|
84044
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84045
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84020
84046
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84021
84047
|
if (errorNode) {
|
|
84022
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84048
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84049
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84050
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84051
|
+
}
|
|
84023
84052
|
}
|
|
84024
84053
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84025
84054
|
return undefined;
|
|
84026
84055
|
}
|
|
84027
|
-
else {
|
|
84028
|
-
|
|
84056
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84057
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84058
|
+
var diag = _g[_f];
|
|
84059
|
+
diagnostics.add(diag);
|
|
84060
|
+
}
|
|
84029
84061
|
}
|
|
84062
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84030
84063
|
}
|
|
84031
84064
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84032
84065
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84054,47 +84087,62 @@ var ts;
|
|
|
84054
84087
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84055
84088
|
* `getIterationTypesOfIterable` instead.
|
|
84056
84089
|
*/
|
|
84057
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84090
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84058
84091
|
if (isTypeAny(type)) {
|
|
84059
84092
|
return anyIterationTypes;
|
|
84060
84093
|
}
|
|
84094
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84095
|
+
// In addition, we should not cache any new results for this call.
|
|
84096
|
+
var noCache = false;
|
|
84061
84097
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84062
84098
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84063
84099
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84064
84100
|
if (iterationTypes) {
|
|
84065
|
-
|
|
84066
|
-
|
|
84067
|
-
|
|
84101
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84102
|
+
// ignore the cached value
|
|
84103
|
+
noCache = true;
|
|
84104
|
+
}
|
|
84105
|
+
else {
|
|
84106
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84107
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84108
|
+
iterationTypes;
|
|
84109
|
+
}
|
|
84068
84110
|
}
|
|
84069
84111
|
}
|
|
84070
84112
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84071
84113
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84072
84114
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84073
84115
|
if (iterationTypes) {
|
|
84074
|
-
if (
|
|
84075
|
-
//
|
|
84076
|
-
|
|
84077
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84078
|
-
}
|
|
84116
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84117
|
+
// ignore the cached value
|
|
84118
|
+
noCache = true;
|
|
84079
84119
|
}
|
|
84080
84120
|
else {
|
|
84081
|
-
|
|
84121
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84122
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84123
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84124
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84125
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84126
|
+
}
|
|
84127
|
+
}
|
|
84128
|
+
else {
|
|
84129
|
+
return iterationTypes;
|
|
84130
|
+
}
|
|
84082
84131
|
}
|
|
84083
84132
|
}
|
|
84084
84133
|
}
|
|
84085
84134
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84086
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84135
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84087
84136
|
if (iterationTypes !== noIterationTypes) {
|
|
84088
84137
|
return iterationTypes;
|
|
84089
84138
|
}
|
|
84090
84139
|
}
|
|
84091
84140
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84092
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84141
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84093
84142
|
if (iterationTypes !== noIterationTypes) {
|
|
84094
84143
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84095
|
-
|
|
84096
|
-
|
|
84097
|
-
: noIterationTypes);
|
|
84144
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84145
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84098
84146
|
}
|
|
84099
84147
|
else {
|
|
84100
84148
|
return iterationTypes;
|
|
@@ -84115,7 +84163,7 @@ var ts;
|
|
|
84115
84163
|
}
|
|
84116
84164
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84117
84165
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84118
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84166
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84119
84167
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84120
84168
|
}
|
|
84121
84169
|
/**
|
|
@@ -84169,26 +84217,26 @@ var ts;
|
|
|
84169
84217
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84170
84218
|
* `getIterationTypesOfIterable` instead.
|
|
84171
84219
|
*/
|
|
84172
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84220
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84173
84221
|
var _a;
|
|
84174
84222
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84175
84223
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84176
84224
|
if (isTypeAny(methodType)) {
|
|
84177
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84225
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84178
84226
|
}
|
|
84179
84227
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84180
84228
|
if (!ts.some(signatures)) {
|
|
84181
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84229
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84182
84230
|
}
|
|
84183
84231
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84184
|
-
var iterationTypes = (_a =
|
|
84185
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84232
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84233
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84186
84234
|
}
|
|
84187
84235
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84188
84236
|
var message = allowAsyncIterables
|
|
84189
84237
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84190
84238
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84191
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84239
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84192
84240
|
}
|
|
84193
84241
|
/**
|
|
84194
84242
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -84196,13 +84244,29 @@ var ts;
|
|
|
84196
84244
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84197
84245
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84198
84246
|
*/
|
|
84199
|
-
function getIterationTypesOfIterator(type, resolver, errorNode) {
|
|
84247
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84248
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84249
|
+
}
|
|
84250
|
+
/**
|
|
84251
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84252
|
+
*
|
|
84253
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84254
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84255
|
+
*
|
|
84256
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84257
|
+
* `getIterationTypesOfIterator` instead.
|
|
84258
|
+
*/
|
|
84259
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84200
84260
|
if (isTypeAny(type)) {
|
|
84201
84261
|
return anyIterationTypes;
|
|
84202
84262
|
}
|
|
84203
84263
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84204
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84205
|
-
|
|
84264
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84265
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84266
|
+
iterationTypes = undefined;
|
|
84267
|
+
noCache = true;
|
|
84268
|
+
}
|
|
84269
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84206
84270
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84207
84271
|
}
|
|
84208
84272
|
/**
|
|
@@ -84240,7 +84304,7 @@ var ts;
|
|
|
84240
84304
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84241
84305
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84242
84306
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84243
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84307
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84244
84308
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84245
84309
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84246
84310
|
}
|
|
@@ -84310,8 +84374,8 @@ var ts;
|
|
|
84310
84374
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84311
84375
|
* record is returned. Otherwise, we return `undefined`.
|
|
84312
84376
|
*/
|
|
84313
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84314
|
-
var _a, _b, _c, _d;
|
|
84377
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84378
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84315
84379
|
var method = getPropertyOfType(type, methodName);
|
|
84316
84380
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84317
84381
|
if (!method && methodName !== "next") {
|
|
@@ -84331,9 +84395,15 @@ var ts;
|
|
|
84331
84395
|
var diagnostic = methodName === "next"
|
|
84332
84396
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84333
84397
|
: resolver.mustBeAMethodDiagnostic;
|
|
84334
|
-
|
|
84398
|
+
if (errorOutputContainer) {
|
|
84399
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84400
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84401
|
+
}
|
|
84402
|
+
else {
|
|
84403
|
+
error(errorNode, diagnostic, methodName);
|
|
84404
|
+
}
|
|
84335
84405
|
}
|
|
84336
|
-
return methodName === "next" ?
|
|
84406
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84337
84407
|
}
|
|
84338
84408
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84339
84409
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84345,8 +84415,8 @@ var ts;
|
|
|
84345
84415
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84346
84416
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84347
84417
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84348
|
-
var isGeneratorMethod = ((
|
|
84349
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84418
|
+
var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol;
|
|
84419
|
+
var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol;
|
|
84350
84420
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84351
84421
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84352
84422
|
var mapper = methodType.mapper;
|
|
@@ -84386,7 +84456,13 @@ var ts;
|
|
|
84386
84456
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84387
84457
|
if (iterationTypes === noIterationTypes) {
|
|
84388
84458
|
if (errorNode) {
|
|
84389
|
-
|
|
84459
|
+
if (errorOutputContainer) {
|
|
84460
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84461
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84462
|
+
}
|
|
84463
|
+
else {
|
|
84464
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84465
|
+
}
|
|
84390
84466
|
}
|
|
84391
84467
|
yieldType = anyType;
|
|
84392
84468
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84407,13 +84483,13 @@ var ts;
|
|
|
84407
84483
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84408
84484
|
* `getIterationTypesOfIterator` instead.
|
|
84409
84485
|
*/
|
|
84410
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84486
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84411
84487
|
var iterationTypes = combineIterationTypes([
|
|
84412
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84413
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84414
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84488
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84489
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84490
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84415
84491
|
]);
|
|
84416
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84492
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84417
84493
|
}
|
|
84418
84494
|
/**
|
|
84419
84495
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84434,7 +84510,7 @@ var ts;
|
|
|
84434
84510
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84435
84511
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84436
84512
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84437
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84513
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84438
84514
|
}
|
|
84439
84515
|
function checkBreakOrContinueStatement(node) {
|
|
84440
84516
|
// Grammar checking
|
|
@@ -94891,10 +94967,11 @@ var ts;
|
|
|
94891
94967
|
}
|
|
94892
94968
|
function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
|
|
94893
94969
|
if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
|
|
94894
|
-
|
|
94970
|
+
var operand = ts.skipParentheses(node.operand);
|
|
94971
|
+
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
|
|
94895
94972
|
var info = void 0;
|
|
94896
|
-
if (info = accessPrivateIdentifier(
|
|
94897
|
-
var receiver = ts.visitNode(
|
|
94973
|
+
if (info = accessPrivateIdentifier(operand.name)) {
|
|
94974
|
+
var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
|
|
94898
94975
|
var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
|
|
94899
94976
|
var expression = createPrivateIdentifierAccess(info, readExpression);
|
|
94900
94977
|
var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
@@ -94910,7 +94987,7 @@ var ts;
|
|
|
94910
94987
|
}
|
|
94911
94988
|
}
|
|
94912
94989
|
else if (shouldTransformSuperInStaticInitializers &&
|
|
94913
|
-
ts.isSuperProperty(
|
|
94990
|
+
ts.isSuperProperty(operand) &&
|
|
94914
94991
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
94915
94992
|
currentClassLexicalEnvironment) {
|
|
94916
94993
|
// converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
|
|
@@ -94923,31 +95000,31 @@ var ts;
|
|
|
94923
95000
|
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
|
|
94924
95001
|
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
|
|
94925
95002
|
if (facts & 1 /* ClassWasDecorated */) {
|
|
94926
|
-
var
|
|
95003
|
+
var expression = visitInvalidSuperProperty(operand);
|
|
94927
95004
|
return ts.isPrefixUnaryExpression(node) ?
|
|
94928
|
-
factory.updatePrefixUnaryExpression(node,
|
|
94929
|
-
factory.updatePostfixUnaryExpression(node,
|
|
95005
|
+
factory.updatePrefixUnaryExpression(node, expression) :
|
|
95006
|
+
factory.updatePostfixUnaryExpression(node, expression);
|
|
94930
95007
|
}
|
|
94931
95008
|
if (classConstructor && superClassReference) {
|
|
94932
95009
|
var setterName = void 0;
|
|
94933
95010
|
var getterName = void 0;
|
|
94934
|
-
if (ts.isPropertyAccessExpression(
|
|
94935
|
-
if (ts.isIdentifier(
|
|
94936
|
-
getterName = setterName = factory.createStringLiteralFromNode(
|
|
95011
|
+
if (ts.isPropertyAccessExpression(operand)) {
|
|
95012
|
+
if (ts.isIdentifier(operand.name)) {
|
|
95013
|
+
getterName = setterName = factory.createStringLiteralFromNode(operand.name);
|
|
94937
95014
|
}
|
|
94938
95015
|
}
|
|
94939
95016
|
else {
|
|
94940
|
-
if (ts.isSimpleInlineableExpression(
|
|
94941
|
-
getterName = setterName =
|
|
95017
|
+
if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
|
|
95018
|
+
getterName = setterName = operand.argumentExpression;
|
|
94942
95019
|
}
|
|
94943
95020
|
else {
|
|
94944
95021
|
getterName = factory.createTempVariable(hoistVariableDeclaration);
|
|
94945
|
-
setterName = factory.createAssignment(getterName, ts.visitNode(
|
|
95022
|
+
setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
|
|
94946
95023
|
}
|
|
94947
95024
|
}
|
|
94948
95025
|
if (setterName && getterName) {
|
|
94949
95026
|
var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
|
|
94950
|
-
ts.setTextRange(expression,
|
|
95027
|
+
ts.setTextRange(expression, operand);
|
|
94951
95028
|
var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
94952
95029
|
expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
|
|
94953
95030
|
expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
|
|
@@ -117702,6 +117779,12 @@ var ts;
|
|
|
117702
117779
|
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
117703
117780
|
*/
|
|
117704
117781
|
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
117782
|
+
var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
|
117783
|
+
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
117784
|
+
}
|
|
117785
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
117786
|
+
/*@internal*/
|
|
117787
|
+
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
117705
117788
|
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
117706
117789
|
case ts.ModuleResolutionKind.Node16:
|
|
117707
117790
|
case ts.ModuleResolutionKind.NodeNext:
|
|
@@ -117713,11 +117796,16 @@ var ts;
|
|
|
117713
117796
|
return undefined;
|
|
117714
117797
|
}
|
|
117715
117798
|
function lookupFromPackageJson() {
|
|
117716
|
-
var
|
|
117717
|
-
|
|
117799
|
+
var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
117800
|
+
var packageJsonLocations = [];
|
|
117801
|
+
state.failedLookupLocations = packageJsonLocations;
|
|
117802
|
+
state.affectingLocations = packageJsonLocations;
|
|
117803
|
+
var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
|
|
117804
|
+
var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
117805
|
+
return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
|
|
117718
117806
|
}
|
|
117719
117807
|
}
|
|
117720
|
-
ts.
|
|
117808
|
+
ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
|
|
117721
117809
|
/** @internal */
|
|
117722
117810
|
ts.plainJSErrors = new ts.Set([
|
|
117723
117811
|
// binder errors
|
|
@@ -118042,7 +118130,7 @@ var ts;
|
|
|
118042
118130
|
for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
|
|
118043
118131
|
var oldSourceFile = oldSourceFiles_1[_i];
|
|
118044
118132
|
var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
|
118045
|
-
if (shouldCreateNewSourceFile || !newFile ||
|
|
118133
|
+
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
118046
118134
|
// old file wasn't redirect but new file is
|
|
118047
118135
|
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
|
118048
118136
|
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
|
@@ -118435,7 +118523,7 @@ var ts;
|
|
|
118435
118523
|
});
|
|
118436
118524
|
}
|
|
118437
118525
|
function tryReuseStructureFromOldProgram() {
|
|
118438
|
-
var _a;
|
|
118526
|
+
var _a, _b;
|
|
118439
118527
|
if (!oldProgram) {
|
|
118440
118528
|
return 0 /* Not */;
|
|
118441
118529
|
}
|
|
@@ -118476,12 +118564,15 @@ var ts;
|
|
|
118476
118564
|
var seenPackageNames = new ts.Map();
|
|
118477
118565
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
118478
118566
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
118567
|
+
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
118479
118568
|
var newSourceFile = host.getSourceFileByPath
|
|
118480
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath,
|
|
118481
|
-
: host.getSourceFile(oldSourceFile.fileName,
|
|
118569
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
|
118570
|
+
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
|
118482
118571
|
if (!newSourceFile) {
|
|
118483
118572
|
return 0 /* Not */;
|
|
118484
118573
|
}
|
|
118574
|
+
newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
118575
|
+
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
118485
118576
|
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
|
118486
118577
|
var fileChanged = void 0;
|
|
118487
118578
|
if (oldSourceFile.redirectInfo) {
|
|
@@ -118521,38 +118612,43 @@ var ts;
|
|
|
118521
118612
|
seenPackageNames.set(packageName, newKind);
|
|
118522
118613
|
}
|
|
118523
118614
|
if (fileChanged) {
|
|
118615
|
+
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
|
118616
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118617
|
+
}
|
|
118524
118618
|
// The `newSourceFile` object was created for the new program.
|
|
118525
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118619
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118526
118620
|
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
|
118527
118621
|
structureIsReused = 1 /* SafeModules */;
|
|
118528
118622
|
}
|
|
118529
|
-
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118623
|
+
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118530
118624
|
// value of no-default-lib has changed
|
|
118531
118625
|
// this will affect if default library is injected into the list of files
|
|
118532
118626
|
structureIsReused = 1 /* SafeModules */;
|
|
118533
118627
|
}
|
|
118534
118628
|
// check tripleslash references
|
|
118535
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118629
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118536
118630
|
// tripleslash references has changed
|
|
118537
118631
|
structureIsReused = 1 /* SafeModules */;
|
|
118538
118632
|
}
|
|
118539
|
-
|
|
118540
|
-
|
|
118541
|
-
|
|
118542
|
-
|
|
118543
|
-
|
|
118544
|
-
|
|
118545
|
-
|
|
118546
|
-
|
|
118547
|
-
|
|
118548
|
-
|
|
118549
|
-
|
|
118550
|
-
|
|
118551
|
-
|
|
118552
|
-
|
|
118553
|
-
|
|
118554
|
-
|
|
118555
|
-
|
|
118633
|
+
else {
|
|
118634
|
+
// check imports and module augmentations
|
|
118635
|
+
collectExternalModuleReferences(newSourceFile);
|
|
118636
|
+
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
|
118637
|
+
// imports has changed
|
|
118638
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118639
|
+
}
|
|
118640
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
|
118641
|
+
// moduleAugmentations has changed
|
|
118642
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118643
|
+
}
|
|
118644
|
+
else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
118645
|
+
// dynamicImport has changed
|
|
118646
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118647
|
+
}
|
|
118648
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118649
|
+
// 'types' references has changed
|
|
118650
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118651
|
+
}
|
|
118556
118652
|
}
|
|
118557
118653
|
// tentatively approve the file
|
|
118558
118654
|
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
|
@@ -118570,18 +118666,18 @@ var ts;
|
|
|
118570
118666
|
return structureIsReused;
|
|
118571
118667
|
}
|
|
118572
118668
|
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
|
|
118573
|
-
for (var
|
|
118574
|
-
var oldFile = oldSourceFiles_3[
|
|
118669
|
+
for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
|
|
118670
|
+
var oldFile = oldSourceFiles_3[_c];
|
|
118575
118671
|
if (!ts.contains(modifiedFiles, oldFile)) {
|
|
118576
|
-
for (var
|
|
118577
|
-
var moduleName = _d
|
|
118672
|
+
for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
|
|
118673
|
+
var moduleName = _e[_d];
|
|
118578
118674
|
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
118579
118675
|
}
|
|
118580
118676
|
}
|
|
118581
118677
|
}
|
|
118582
118678
|
// try to verify results of module resolution
|
|
118583
|
-
for (var
|
|
118584
|
-
var
|
|
118679
|
+
for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
|
|
118680
|
+
var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
|
|
118585
118681
|
var moduleNames = getModuleNames(newSourceFile);
|
|
118586
118682
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
118587
118683
|
// ensure that module resolution results are still correct
|
|
@@ -118608,14 +118704,14 @@ var ts;
|
|
|
118608
118704
|
if (structureIsReused !== 2 /* Completely */) {
|
|
118609
118705
|
return structureIsReused;
|
|
118610
118706
|
}
|
|
118611
|
-
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((
|
|
118707
|
+
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
|
|
118612
118708
|
return 1 /* SafeModules */;
|
|
118613
118709
|
}
|
|
118614
118710
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
118615
118711
|
// update fileName -> file mapping
|
|
118616
118712
|
ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
118617
|
-
for (var
|
|
118618
|
-
var newSourceFile = newSourceFiles_1[
|
|
118713
|
+
for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
|
|
118714
|
+
var newSourceFile = newSourceFiles_1[_h];
|
|
118619
118715
|
filesByName.set(newSourceFile.path, newSourceFile);
|
|
118620
118716
|
}
|
|
118621
118717
|
var oldFilesByNameMap = oldProgram.getFilesByNameMap();
|
|
@@ -119398,13 +119494,16 @@ var ts;
|
|
|
119398
119494
|
addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
|
|
119399
119495
|
}
|
|
119400
119496
|
}
|
|
119401
|
-
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
|
|
119497
|
+
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
|
|
119498
|
+
var _a;
|
|
119402
119499
|
var redirect = Object.create(redirectTarget);
|
|
119403
119500
|
redirect.fileName = fileName;
|
|
119404
119501
|
redirect.path = path;
|
|
119405
119502
|
redirect.resolvedPath = resolvedPath;
|
|
119406
119503
|
redirect.originalFileName = originalFileName;
|
|
119407
119504
|
redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
|
|
119505
|
+
redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119506
|
+
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119408
119507
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
119409
119508
|
Object.defineProperties(redirect, {
|
|
119410
119509
|
id: {
|
|
@@ -119433,14 +119532,14 @@ var ts;
|
|
|
119433
119532
|
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
|
119434
119533
|
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
|
119435
119534
|
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
|
119436
|
-
var
|
|
119437
|
-
|
|
119438
|
-
|
|
119439
|
-
|
|
119440
|
-
setExternalModuleIndicator:
|
|
119441
|
-
};
|
|
119535
|
+
var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
119536
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
119537
|
+
var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
|
|
119538
|
+
return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
|
|
119539
|
+
{ languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
|
|
119442
119540
|
}
|
|
119443
119541
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
119542
|
+
var _a, _b;
|
|
119444
119543
|
var path = toPath(fileName);
|
|
119445
119544
|
if (useSourceOfProjectReferenceRedirect) {
|
|
119446
119545
|
var source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -119527,14 +119626,15 @@ var ts;
|
|
|
119527
119626
|
}
|
|
119528
119627
|
}
|
|
119529
119628
|
// We haven't looked for this file, do so now and cache result
|
|
119530
|
-
var
|
|
119629
|
+
var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
119630
|
+
var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
|
|
119531
119631
|
if (packageId) {
|
|
119532
119632
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
119533
119633
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
119534
119634
|
if (fileFromPackageId) {
|
|
119535
119635
|
// Some other SourceFile already exists with this package name and version.
|
|
119536
119636
|
// Instead of creating a duplicate, just redirect to the existing one.
|
|
119537
|
-
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
|
|
119637
|
+
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
|
119538
119638
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
119539
119639
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
119540
119640
|
addFileIncludeReason(dupFile, reason);
|
|
@@ -119555,6 +119655,8 @@ var ts;
|
|
|
119555
119655
|
file.path = path;
|
|
119556
119656
|
file.resolvedPath = toPath(fileName);
|
|
119557
119657
|
file.originalFileName = originalFileName;
|
|
119658
|
+
file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119659
|
+
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119558
119660
|
addFileIncludeReason(file, reason);
|
|
119559
119661
|
if (host.useCaseSensitiveFileNames()) {
|
|
119560
119662
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -120185,7 +120287,7 @@ var ts;
|
|
|
120185
120287
|
fileIncludeReasons = undefined;
|
|
120186
120288
|
var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
|
|
120187
120289
|
var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
120188
|
-
var redirectInfo = file && ts.
|
|
120290
|
+
var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
|
|
120189
120291
|
var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
|
|
120190
120292
|
return location && isReferenceFileLocation(location) ?
|
|
120191
120293
|
ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
|
|
@@ -122490,7 +122592,7 @@ var ts;
|
|
|
122490
122592
|
* "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
|
|
122491
122593
|
* @param dirPath
|
|
122492
122594
|
*/
|
|
122493
|
-
function
|
|
122595
|
+
function canWatchDirectoryOrFile(dirPath) {
|
|
122494
122596
|
var rootLength = ts.getRootLength(dirPath);
|
|
122495
122597
|
if (dirPath.length === rootLength) {
|
|
122496
122598
|
// Ignore "/", "c:/"
|
|
@@ -122527,7 +122629,7 @@ var ts;
|
|
|
122527
122629
|
}
|
|
122528
122630
|
return true;
|
|
122529
122631
|
}
|
|
122530
|
-
ts.
|
|
122632
|
+
ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
|
|
122531
122633
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
122532
122634
|
var filesWithChangedSetOfUnresolvedImports;
|
|
122533
122635
|
var filesWithInvalidatedResolutions;
|
|
@@ -122536,7 +122638,9 @@ var ts;
|
|
|
122536
122638
|
var resolutionsWithFailedLookups = [];
|
|
122537
122639
|
var resolutionsWithOnlyAffectingLocations = [];
|
|
122538
122640
|
var resolvedFileToResolution = ts.createMultiMap();
|
|
122641
|
+
var impliedFormatPackageJsons = new ts.Map();
|
|
122539
122642
|
var hasChangedAutomaticTypeDirectiveNames = false;
|
|
122643
|
+
var affectingPathChecksForFile;
|
|
122540
122644
|
var affectingPathChecks;
|
|
122541
122645
|
var failedLookupChecks;
|
|
122542
122646
|
var startsWithPathChecks;
|
|
@@ -122576,7 +122680,7 @@ var ts;
|
|
|
122576
122680
|
finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
|
|
122577
122681
|
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122578
122682
|
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122579
|
-
startCachingPerDirectoryResolution:
|
|
122683
|
+
startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
|
|
122580
122684
|
finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
|
|
122581
122685
|
resolveModuleNames: resolveModuleNames,
|
|
122582
122686
|
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
@@ -122620,9 +122724,10 @@ var ts;
|
|
|
122620
122724
|
startsWithPathChecks = undefined;
|
|
122621
122725
|
isInDirectoryChecks = undefined;
|
|
122622
122726
|
affectingPathChecks = undefined;
|
|
122623
|
-
|
|
122624
|
-
|
|
122625
|
-
|
|
122727
|
+
affectingPathChecksForFile = undefined;
|
|
122728
|
+
moduleResolutionCache.clear();
|
|
122729
|
+
typeReferenceDirectiveResolutionCache.clear();
|
|
122730
|
+
impliedFormatPackageJsons.clear();
|
|
122626
122731
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122627
122732
|
}
|
|
122628
122733
|
function startRecordingFilesWithChangedResolutions() {
|
|
@@ -122654,15 +122759,44 @@ var ts;
|
|
|
122654
122759
|
return function (path) { return (!!collected && collected.has(path)) ||
|
|
122655
122760
|
isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
|
|
122656
122761
|
}
|
|
122657
|
-
function
|
|
122658
|
-
moduleResolutionCache.
|
|
122659
|
-
typeReferenceDirectiveResolutionCache.
|
|
122762
|
+
function startCachingPerDirectoryResolution() {
|
|
122763
|
+
moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122764
|
+
typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122765
|
+
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122766
|
+
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122660
122767
|
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122661
122768
|
nonRelativeExternalModuleResolutions.clear();
|
|
122662
122769
|
}
|
|
122663
|
-
function finishCachingPerDirectoryResolution() {
|
|
122770
|
+
function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
|
|
122664
122771
|
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
|
122665
|
-
|
|
122772
|
+
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122773
|
+
nonRelativeExternalModuleResolutions.clear();
|
|
122774
|
+
// Update file watches
|
|
122775
|
+
if (newProgram !== oldProgram) {
|
|
122776
|
+
newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
|
|
122777
|
+
var _a, _b, _c;
|
|
122778
|
+
var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
122779
|
+
var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
|
|
122780
|
+
for (var i = existing.length; i < expected; i++) {
|
|
122781
|
+
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
|
|
122782
|
+
}
|
|
122783
|
+
if (existing.length > expected) {
|
|
122784
|
+
for (var i = expected; i < existing.length; i++) {
|
|
122785
|
+
fileWatchesOfAffectingLocations.get(existing[i]).files--;
|
|
122786
|
+
}
|
|
122787
|
+
}
|
|
122788
|
+
if (expected)
|
|
122789
|
+
impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
|
|
122790
|
+
else
|
|
122791
|
+
impliedFormatPackageJsons.delete(newFile.path);
|
|
122792
|
+
});
|
|
122793
|
+
impliedFormatPackageJsons.forEach(function (existing, path) {
|
|
122794
|
+
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
122795
|
+
existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
|
|
122796
|
+
impliedFormatPackageJsons.delete(path);
|
|
122797
|
+
}
|
|
122798
|
+
});
|
|
122799
|
+
}
|
|
122666
122800
|
directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
|
|
122667
122801
|
if (watcher.refCount === 0) {
|
|
122668
122802
|
directoryWatchesOfFailedLookups.delete(path);
|
|
@@ -122670,11 +122804,9 @@ var ts;
|
|
|
122670
122804
|
}
|
|
122671
122805
|
});
|
|
122672
122806
|
fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
|
|
122673
|
-
if (watcher.
|
|
122807
|
+
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122674
122808
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122675
122809
|
watcher.watcher.close();
|
|
122676
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122677
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122678
122810
|
}
|
|
122679
122811
|
});
|
|
122680
122812
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -122901,7 +123033,7 @@ var ts;
|
|
|
122901
123033
|
}
|
|
122902
123034
|
// If the directory is node_modules use it to watch, always watch it recursively
|
|
122903
123035
|
if (ts.isNodeModulesDirectory(dirPath)) {
|
|
122904
|
-
return
|
|
123036
|
+
return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
|
|
122905
123037
|
}
|
|
122906
123038
|
var nonRecursive = true;
|
|
122907
123039
|
// Use some ancestor of the root directory
|
|
@@ -122919,7 +123051,7 @@ var ts;
|
|
|
122919
123051
|
dir = ts.getDirectoryPath(dir);
|
|
122920
123052
|
}
|
|
122921
123053
|
}
|
|
122922
|
-
return
|
|
123054
|
+
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
|
|
122923
123055
|
}
|
|
122924
123056
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
122925
123057
|
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
@@ -122990,46 +123122,65 @@ var ts;
|
|
|
122990
123122
|
// Watch package json
|
|
122991
123123
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122992
123124
|
var affectingLocation = affectingLocations_1[_i];
|
|
122993
|
-
createFileWatcherOfAffectingLocation(affectingLocation);
|
|
123125
|
+
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
|
122994
123126
|
}
|
|
122995
123127
|
}
|
|
122996
|
-
function createFileWatcherOfAffectingLocation(affectingLocation) {
|
|
122997
|
-
var
|
|
122998
|
-
var fileWatcher = fileWatchesOfAffectingLocations.get(path);
|
|
123128
|
+
function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
|
|
123129
|
+
var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
122999
123130
|
if (fileWatcher) {
|
|
123000
|
-
|
|
123131
|
+
if (forResolution)
|
|
123132
|
+
fileWatcher.resolutions++;
|
|
123133
|
+
else
|
|
123134
|
+
fileWatcher.files++;
|
|
123001
123135
|
return;
|
|
123002
123136
|
}
|
|
123003
123137
|
var locationToWatch = affectingLocation;
|
|
123004
|
-
var locationToWatchPath = path;
|
|
123005
123138
|
if (resolutionHost.realpath) {
|
|
123006
123139
|
locationToWatch = resolutionHost.realpath(affectingLocation);
|
|
123007
|
-
|
|
123008
|
-
|
|
123009
|
-
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
|
|
123140
|
+
if (affectingLocation !== locationToWatch) {
|
|
123141
|
+
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
|
|
123010
123142
|
if (fileWatcher_1) {
|
|
123011
|
-
|
|
123012
|
-
|
|
123013
|
-
|
|
123143
|
+
if (forResolution)
|
|
123144
|
+
fileWatcher_1.resolutions++;
|
|
123145
|
+
else
|
|
123146
|
+
fileWatcher_1.files++;
|
|
123147
|
+
fileWatcher_1.paths.add(affectingLocation);
|
|
123148
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
|
|
123014
123149
|
return;
|
|
123015
123150
|
}
|
|
123016
123151
|
}
|
|
123017
123152
|
}
|
|
123018
123153
|
var paths = new ts.Set();
|
|
123019
|
-
paths.add(
|
|
123020
|
-
var
|
|
123021
|
-
|
|
123022
|
-
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName,
|
|
123023
|
-
|
|
123154
|
+
paths.add(locationToWatch);
|
|
123155
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123156
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123157
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123158
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123159
|
+
paths.forEach(function (path) {
|
|
123160
|
+
if (watcher.resolutions)
|
|
123161
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123162
|
+
if (watcher.files)
|
|
123163
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123164
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123165
|
+
});
|
|
123024
123166
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123025
|
-
})
|
|
123026
|
-
|
|
123167
|
+
}) : ts.noopFileWatcher;
|
|
123168
|
+
var watcher = {
|
|
123169
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123170
|
+
close: function () {
|
|
123171
|
+
actualWatcher.close();
|
|
123172
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123173
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123174
|
+
}
|
|
123175
|
+
} : actualWatcher,
|
|
123176
|
+
resolutions: forResolution ? 1 : 0,
|
|
123177
|
+
files: forResolution ? 0 : 1,
|
|
123027
123178
|
paths: paths,
|
|
123028
123179
|
};
|
|
123029
|
-
fileWatchesOfAffectingLocations.set(
|
|
123030
|
-
if (
|
|
123031
|
-
fileWatchesOfAffectingLocations.set(
|
|
123032
|
-
paths.add(
|
|
123180
|
+
fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
|
|
123181
|
+
if (affectingLocation !== locationToWatch) {
|
|
123182
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
|
|
123183
|
+
paths.add(affectingLocation);
|
|
123033
123184
|
}
|
|
123034
123185
|
}
|
|
123035
123186
|
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
|
|
@@ -123097,8 +123248,8 @@ var ts;
|
|
|
123097
123248
|
}
|
|
123098
123249
|
for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
|
|
123099
123250
|
var affectingLocation = affectingLocations_2[_a];
|
|
123100
|
-
var watcher = fileWatchesOfAffectingLocations.get(
|
|
123101
|
-
watcher.
|
|
123251
|
+
var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123252
|
+
watcher.resolutions--;
|
|
123102
123253
|
}
|
|
123103
123254
|
}
|
|
123104
123255
|
function removeDirectoryWatcher(dirPath) {
|
|
@@ -123152,7 +123303,7 @@ var ts;
|
|
|
123152
123303
|
resolution.isInvalidated = invalidated = true;
|
|
123153
123304
|
for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
|
|
123154
123305
|
var containingFilePath = _b[_a];
|
|
123155
|
-
(filesWithInvalidatedResolutions
|
|
123306
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
|
|
123156
123307
|
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
|
123157
123308
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
|
|
123158
123309
|
}
|
|
@@ -123219,10 +123370,25 @@ var ts;
|
|
|
123219
123370
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123220
123371
|
}
|
|
123221
123372
|
function invalidateResolutionsOfFailedLookupLocations() {
|
|
123373
|
+
var _a;
|
|
123374
|
+
var invalidated = false;
|
|
123375
|
+
if (affectingPathChecksForFile) {
|
|
123376
|
+
(_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
|
|
123377
|
+
if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
|
|
123378
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
|
|
123379
|
+
invalidated = true;
|
|
123380
|
+
}
|
|
123381
|
+
});
|
|
123382
|
+
affectingPathChecksForFile = undefined;
|
|
123383
|
+
}
|
|
123222
123384
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
|
123223
|
-
return
|
|
123385
|
+
return invalidated;
|
|
123386
|
+
}
|
|
123387
|
+
invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
|
|
123388
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123389
|
+
if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
|
|
123390
|
+
packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
|
|
123224
123391
|
}
|
|
123225
|
-
var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
|
|
123226
123392
|
failedLookupChecks = undefined;
|
|
123227
123393
|
startsWithPathChecks = undefined;
|
|
123228
123394
|
isInDirectoryChecks = undefined;
|
|
@@ -123235,17 +123401,15 @@ var ts;
|
|
|
123235
123401
|
return true;
|
|
123236
123402
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
|
|
123237
123403
|
return false;
|
|
123238
|
-
return resolution.failedLookupLocations.some(function (location) {
|
|
123239
|
-
|
|
123240
|
-
|
|
123241
|
-
|
|
123242
|
-
|
|
123243
|
-
|
|
123404
|
+
return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
|
|
123405
|
+
}
|
|
123406
|
+
function isInvalidatedFailedLookup(locationPath) {
|
|
123407
|
+
return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
|
|
123408
|
+
ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
|
|
123409
|
+
ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
|
|
123244
123410
|
}
|
|
123245
123411
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
123246
|
-
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
|
|
123247
|
-
return affectingPathChecks.has(resolutionHost.toPath(location));
|
|
123248
|
-
});
|
|
123412
|
+
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
|
|
123249
123413
|
}
|
|
123250
123414
|
function closeTypeRootsWatch() {
|
|
123251
123415
|
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
|
|
@@ -123311,7 +123475,7 @@ var ts;
|
|
|
123311
123475
|
function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
|
|
123312
123476
|
var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
|
|
123313
123477
|
var dirPath = resolutionHost.toPath(dir);
|
|
123314
|
-
return dirPath === rootPath ||
|
|
123478
|
+
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
123315
123479
|
}
|
|
123316
123480
|
}
|
|
123317
123481
|
ts.createResolutionCache = createResolutionCache;
|
|
@@ -123422,7 +123586,7 @@ var ts;
|
|
|
123422
123586
|
var info = getInfo(importingSourceFileName, host);
|
|
123423
123587
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123424
123588
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123425
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123589
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123426
123590
|
}
|
|
123427
123591
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123428
123592
|
if (options === void 0) { options = {}; }
|
|
@@ -123505,7 +123669,7 @@ var ts;
|
|
|
123505
123669
|
return nodeModulesSpecifiers;
|
|
123506
123670
|
}
|
|
123507
123671
|
if (!specifier && !modulePath.isRedirect) {
|
|
123508
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123672
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123509
123673
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123510
123674
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123511
123675
|
}
|
|
@@ -123533,7 +123697,7 @@ var ts;
|
|
|
123533
123697
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123534
123698
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123535
123699
|
}
|
|
123536
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123700
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123537
123701
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123538
123702
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123539
123703
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123547,9 +123711,8 @@ var ts;
|
|
|
123547
123711
|
if (!relativeToBaseUrl) {
|
|
123548
123712
|
return relativePath;
|
|
123549
123713
|
}
|
|
123550
|
-
var
|
|
123551
|
-
var
|
|
123552
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123714
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123715
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123553
123716
|
if (!nonRelative) {
|
|
123554
123717
|
return relativePath;
|
|
123555
123718
|
}
|
|
@@ -123784,28 +123947,102 @@ var ts;
|
|
|
123784
123947
|
return ambientModuleDeclare.name.text;
|
|
123785
123948
|
}
|
|
123786
123949
|
}
|
|
123787
|
-
function
|
|
123950
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
123951
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
123952
|
+
return [2 /* JsExtension */];
|
|
123953
|
+
}
|
|
123954
|
+
switch (preferredEnding) {
|
|
123955
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
123956
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
123957
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
123958
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
123959
|
+
}
|
|
123960
|
+
}
|
|
123961
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
123788
123962
|
for (var key in paths) {
|
|
123789
|
-
|
|
123790
|
-
var
|
|
123791
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
123963
|
+
var _loop_36 = function (patternText_1) {
|
|
123964
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
123792
123965
|
var indexOfStar = pattern.indexOf("*");
|
|
123966
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
123967
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
123968
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
123969
|
+
// and matches the '*'. For example:
|
|
123970
|
+
//
|
|
123971
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
123972
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
123973
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
123974
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
123975
|
+
//
|
|
123976
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
123977
|
+
//
|
|
123978
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
123979
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
123980
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
123981
|
+
// extension for a module specifier.)
|
|
123982
|
+
//
|
|
123983
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
123984
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
123985
|
+
//
|
|
123986
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
123987
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
123988
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
123989
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
123990
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
123991
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js
|
|
123992
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
123993
|
+
//
|
|
123994
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
123995
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
123996
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
123997
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
123998
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
123999
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124000
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124001
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124002
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124003
|
+
ending: ending,
|
|
124004
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124005
|
+
}); });
|
|
124006
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124007
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124008
|
+
}
|
|
123793
124009
|
if (indexOfStar !== -1) {
|
|
123794
|
-
var prefix = pattern.
|
|
123795
|
-
var suffix = pattern.
|
|
123796
|
-
|
|
123797
|
-
|
|
123798
|
-
|
|
123799
|
-
|
|
123800
|
-
|
|
123801
|
-
|
|
124010
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124011
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124012
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124013
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124014
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124015
|
+
ts.startsWith(value, prefix) &&
|
|
124016
|
+
ts.endsWith(value, suffix) &&
|
|
124017
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124018
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124019
|
+
return { value: key.replace("*", matchedStar) };
|
|
124020
|
+
}
|
|
123802
124021
|
}
|
|
123803
124022
|
}
|
|
123804
|
-
else if (
|
|
123805
|
-
return
|
|
124023
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124024
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124025
|
+
return { value: key };
|
|
123806
124026
|
}
|
|
124027
|
+
};
|
|
124028
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124029
|
+
var patternText_1 = _a[_i];
|
|
124030
|
+
var state_12 = _loop_36(patternText_1);
|
|
124031
|
+
if (typeof state_12 === "object")
|
|
124032
|
+
return state_12.value;
|
|
123807
124033
|
}
|
|
123808
124034
|
}
|
|
124035
|
+
function validateEnding(_a) {
|
|
124036
|
+
var ending = _a.ending, value = _a.value;
|
|
124037
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124038
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124039
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124040
|
+
// do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
|
|
124041
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124042
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124043
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124044
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124045
|
+
}
|
|
123809
124046
|
}
|
|
123810
124047
|
var MatchingMode;
|
|
123811
124048
|
(function (MatchingMode) {
|
|
@@ -123901,10 +124138,10 @@ var ts;
|
|
|
123901
124138
|
return undefined;
|
|
123902
124139
|
}
|
|
123903
124140
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124141
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123904
124142
|
var moduleSpecifier = path;
|
|
123905
124143
|
var isPackageRootPath = false;
|
|
123906
124144
|
if (!packageNameOnly) {
|
|
123907
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123908
124145
|
var packageRootIndex = parts.packageRootIndex;
|
|
123909
124146
|
var moduleFileName = void 0;
|
|
123910
124147
|
while (true) {
|
|
@@ -123953,15 +124190,13 @@ var ts;
|
|
|
123953
124190
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
123954
124191
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
123955
124192
|
var moduleFileToTry = path;
|
|
124193
|
+
var maybeBlockedByTypesVersions = false;
|
|
123956
124194
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
123957
124195
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
123958
124196
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124197
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
123959
124198
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
123960
|
-
|
|
123961
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
123962
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
123963
|
-
// with, so for now we just stick with the mode of the file.
|
|
123964
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124199
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
123965
124200
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
123966
124201
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
123967
124202
|
: undefined;
|
|
@@ -123980,16 +124215,26 @@ var ts;
|
|
|
123980
124215
|
: undefined;
|
|
123981
124216
|
if (versionPaths) {
|
|
123982
124217
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
123983
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
123984
|
-
if (fromPaths
|
|
124218
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124219
|
+
if (fromPaths === undefined) {
|
|
124220
|
+
maybeBlockedByTypesVersions = true;
|
|
124221
|
+
}
|
|
124222
|
+
else {
|
|
123985
124223
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
123986
124224
|
}
|
|
123987
124225
|
}
|
|
123988
124226
|
// If the file is the main module, it can be imported by the package name
|
|
123989
124227
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
123990
|
-
if (ts.isString(mainFileRelative)) {
|
|
124228
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124229
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124230
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124231
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124232
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124233
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124234
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
123991
124235
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
123992
124236
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124237
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
123993
124238
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
123994
124239
|
}
|
|
123995
124240
|
}
|
|
@@ -124284,23 +124529,46 @@ var ts;
|
|
|
124284
124529
|
var file = _c[_i];
|
|
124285
124530
|
write("" + toFileName(file, relativeFileName));
|
|
124286
124531
|
(_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
|
|
124287
|
-
(_b =
|
|
124532
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
|
|
124288
124533
|
}
|
|
124289
124534
|
}
|
|
124290
124535
|
ts.explainFiles = explainFiles;
|
|
124291
|
-
function
|
|
124536
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
124537
|
+
var _a;
|
|
124292
124538
|
var result;
|
|
124293
124539
|
if (file.path !== file.resolvedPath) {
|
|
124294
|
-
(result
|
|
124540
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124295
124541
|
/*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
|
|
124296
124542
|
}
|
|
124297
124543
|
if (file.redirectInfo) {
|
|
124298
|
-
(result
|
|
124544
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124299
124545
|
/*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
|
|
124300
124546
|
}
|
|
124547
|
+
if (ts.isExternalOrCommonJsModule(file)) {
|
|
124548
|
+
switch (file.impliedNodeFormat) {
|
|
124549
|
+
case ts.ModuleKind.ESNext:
|
|
124550
|
+
if (file.packageJsonScope) {
|
|
124551
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124552
|
+
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124553
|
+
}
|
|
124554
|
+
break;
|
|
124555
|
+
case ts.ModuleKind.CommonJS:
|
|
124556
|
+
if (file.packageJsonScope) {
|
|
124557
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124558
|
+
/*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
|
|
124559
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
|
124560
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124561
|
+
}
|
|
124562
|
+
else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
124563
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124564
|
+
/*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
|
|
124565
|
+
}
|
|
124566
|
+
break;
|
|
124567
|
+
}
|
|
124568
|
+
}
|
|
124301
124569
|
return result;
|
|
124302
124570
|
}
|
|
124303
|
-
ts.
|
|
124571
|
+
ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
|
|
124304
124572
|
function getMatchedFileSpec(program, fileName) {
|
|
124305
124573
|
var _a;
|
|
124306
124574
|
var configFile = program.getCompilerOptions().configFile;
|
|
@@ -124510,6 +124778,7 @@ var ts;
|
|
|
124510
124778
|
MissingFile: "Missing file",
|
|
124511
124779
|
WildcardDirectory: "Wild card directory",
|
|
124512
124780
|
FailedLookupLocations: "Failed Lookup Locations",
|
|
124781
|
+
AffectingFileLocation: "File location affecting resolution",
|
|
124513
124782
|
TypeRoots: "Type roots",
|
|
124514
124783
|
ConfigFileOfReferencedProject: "Config file of referened project",
|
|
124515
124784
|
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
|
@@ -124833,7 +125102,7 @@ var ts;
|
|
|
124833
125102
|
compilerHost.getCompilationSettings = function () { return compilerOptions; };
|
|
124834
125103
|
compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
|
|
124835
125104
|
compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
|
|
124836
|
-
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.
|
|
125105
|
+
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
|
|
124837
125106
|
compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
|
|
124838
125107
|
compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
|
|
124839
125108
|
compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
|
|
@@ -124867,6 +125136,9 @@ var ts;
|
|
|
124867
125136
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
124868
125137
|
}) :
|
|
124869
125138
|
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
125139
|
+
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
|
125140
|
+
ts.maybeBind(host, host.getModuleResolutionCache) :
|
|
125141
|
+
(function () { return resolutionCache.getModuleResolutionCache(); });
|
|
124870
125142
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
124871
125143
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
124872
125144
|
synchronizeProgram();
|
|
@@ -124969,8 +125241,9 @@ var ts;
|
|
|
124969
125241
|
resolutionCache.startCachingPerDirectoryResolution();
|
|
124970
125242
|
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
|
|
124971
125243
|
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
|
125244
|
+
var oldProgram = getCurrentProgram();
|
|
124972
125245
|
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
124973
|
-
resolutionCache.finishCachingPerDirectoryResolution();
|
|
125246
|
+
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
|
124974
125247
|
// Update watches
|
|
124975
125248
|
ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
|
|
124976
125249
|
if (needsUpdateInTypeRootWatch) {
|
|
@@ -125052,9 +125325,6 @@ var ts;
|
|
|
125052
125325
|
sourceFilesCache.set(path, false);
|
|
125053
125326
|
}
|
|
125054
125327
|
}
|
|
125055
|
-
if (sourceFile) {
|
|
125056
|
-
sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
|
125057
|
-
}
|
|
125058
125328
|
return sourceFile;
|
|
125059
125329
|
}
|
|
125060
125330
|
return hostSourceFile.sourceFile;
|
|
@@ -125570,6 +125840,7 @@ var ts;
|
|
|
125570
125840
|
compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
|
|
125571
125841
|
compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
|
|
125572
125842
|
compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
125843
|
+
compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
|
|
125573
125844
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
125574
125845
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
125575
125846
|
if (!compilerHost.resolveModuleNames) {
|
|
@@ -137369,60 +137640,64 @@ var ts;
|
|
|
137369
137640
|
}
|
|
137370
137641
|
return settingsOrHost;
|
|
137371
137642
|
}
|
|
137372
|
-
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
137643
|
+
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137373
137644
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137374
137645
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137375
|
-
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
137646
|
+
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137376
137647
|
}
|
|
137377
|
-
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137378
|
-
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
|
137648
|
+
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137649
|
+
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
|
|
137379
137650
|
}
|
|
137380
|
-
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
137651
|
+
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137381
137652
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137382
137653
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137383
|
-
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
137654
|
+
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137384
137655
|
}
|
|
137385
|
-
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137386
|
-
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
|
137656
|
+
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137657
|
+
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
|
|
137387
137658
|
}
|
|
137388
137659
|
function getDocumentRegistryEntry(bucketEntry, scriptKind) {
|
|
137389
137660
|
var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
|
|
137390
137661
|
ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry);
|
|
137391
137662
|
return entry;
|
|
137392
137663
|
}
|
|
137393
|
-
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
137664
|
+
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) {
|
|
137394
137665
|
var _a, _b, _c, _d;
|
|
137395
137666
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
137396
137667
|
var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
|
|
137397
137668
|
var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
|
|
137398
137669
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
137399
|
-
var sourceFileOptions =
|
|
137400
|
-
|
|
137401
|
-
|
|
137402
|
-
|
|
137403
|
-
|
|
137670
|
+
var sourceFileOptions = typeof languageVersionOrOptions === "object" ?
|
|
137671
|
+
languageVersionOrOptions :
|
|
137672
|
+
{
|
|
137673
|
+
languageVersion: scriptTarget,
|
|
137674
|
+
impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
|
|
137675
|
+
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
|
|
137676
|
+
};
|
|
137677
|
+
sourceFileOptions.languageVersion = scriptTarget;
|
|
137404
137678
|
var oldBucketCount = buckets.size;
|
|
137405
|
-
var
|
|
137679
|
+
var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
|
|
137680
|
+
var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); });
|
|
137406
137681
|
if (ts.tracing) {
|
|
137407
137682
|
if (buckets.size > oldBucketCount) {
|
|
137408
137683
|
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
137409
137684
|
// perhaps they are for two projects that don't have any overlap.
|
|
137410
137685
|
// Bonus: these events can help us interpret the more interesting event below.
|
|
137411
|
-
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key:
|
|
137686
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
|
|
137412
137687
|
}
|
|
137413
137688
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
137414
137689
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
137415
137690
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
137416
137691
|
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
137417
|
-
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !==
|
|
137692
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; });
|
|
137418
137693
|
if (otherBucketKey) {
|
|
137419
|
-
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2:
|
|
137694
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode });
|
|
137420
137695
|
}
|
|
137421
137696
|
}
|
|
137422
137697
|
var bucketEntry = bucket.get(path);
|
|
137423
137698
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
137424
137699
|
if (!entry && externalCache) {
|
|
137425
|
-
var sourceFile = externalCache.getDocument(
|
|
137700
|
+
var sourceFile = externalCache.getDocument(keyWithMode, path);
|
|
137426
137701
|
if (sourceFile) {
|
|
137427
137702
|
ts.Debug.assert(acquiring);
|
|
137428
137703
|
entry = {
|
|
@@ -137436,7 +137711,7 @@ var ts;
|
|
|
137436
137711
|
// Have never seen this file with these settings. Create a new source file for it.
|
|
137437
137712
|
var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
|
|
137438
137713
|
if (externalCache) {
|
|
137439
|
-
externalCache.setDocument(
|
|
137714
|
+
externalCache.setDocument(keyWithMode, path, sourceFile);
|
|
137440
137715
|
}
|
|
137441
137716
|
entry = {
|
|
137442
137717
|
sourceFile: sourceFile,
|
|
@@ -137451,7 +137726,7 @@ var ts;
|
|
|
137451
137726
|
if (entry.sourceFile.version !== version) {
|
|
137452
137727
|
entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217
|
|
137453
137728
|
if (externalCache) {
|
|
137454
|
-
externalCache.setDocument(
|
|
137729
|
+
externalCache.setDocument(keyWithMode, path, entry.sourceFile);
|
|
137455
137730
|
}
|
|
137456
137731
|
}
|
|
137457
137732
|
// If we're acquiring, then this is the first time this LS is asking for this document.
|
|
@@ -137480,13 +137755,13 @@ var ts;
|
|
|
137480
137755
|
}
|
|
137481
137756
|
}
|
|
137482
137757
|
}
|
|
137483
|
-
function releaseDocument(fileName, compilationSettings, scriptKind) {
|
|
137758
|
+
function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) {
|
|
137484
137759
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137485
137760
|
var key = getKeyForCompilationSettings(compilationSettings);
|
|
137486
|
-
return releaseDocumentWithKey(path, key, scriptKind);
|
|
137761
|
+
return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
|
|
137487
137762
|
}
|
|
137488
|
-
function releaseDocumentWithKey(path, key, scriptKind) {
|
|
137489
|
-
var bucket = ts.Debug.checkDefined(buckets.get(key));
|
|
137763
|
+
function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) {
|
|
137764
|
+
var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
|
|
137490
137765
|
var bucketEntry = bucket.get(path);
|
|
137491
137766
|
var entry = getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
137492
137767
|
entry.languageServiceRefCount--;
|
|
@@ -137543,6 +137818,9 @@ var ts;
|
|
|
137543
137818
|
function getKeyForCompilationSettings(settings) {
|
|
137544
137819
|
return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
|
|
137545
137820
|
}
|
|
137821
|
+
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
137822
|
+
return (mode ? key + "|" + mode : key);
|
|
137823
|
+
}
|
|
137546
137824
|
})(ts || (ts = {}));
|
|
137547
137825
|
/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
|
|
137548
137826
|
/* @internal */
|
|
@@ -161602,6 +161880,9 @@ var ts;
|
|
|
161602
161880
|
if (!containingDecl) {
|
|
161603
161881
|
return;
|
|
161604
161882
|
}
|
|
161883
|
+
if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
|
|
161884
|
+
return;
|
|
161885
|
+
}
|
|
161605
161886
|
var checker = program.getTypeChecker();
|
|
161606
161887
|
var signatureSymbol = containingDecl.symbol;
|
|
161607
161888
|
if (!signatureSymbol) {
|
|
@@ -166786,12 +167067,12 @@ var ts;
|
|
|
166786
167067
|
// not part of the new program.
|
|
166787
167068
|
function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
|
|
166788
167069
|
var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
|
|
166789
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
|
|
167070
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
166790
167071
|
}
|
|
166791
|
-
function getOrCreateSourceFile(fileName,
|
|
166792
|
-
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName),
|
|
167072
|
+
function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
167073
|
+
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
166793
167074
|
}
|
|
166794
|
-
function getOrCreateSourceFileByPath(fileName, path,
|
|
167075
|
+
function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) {
|
|
166795
167076
|
ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
|
|
166796
167077
|
// The program is asking for this file, check first if the host can locate it.
|
|
166797
167078
|
// If the host can not locate the file, then it does not exist. return undefined
|
|
@@ -166834,17 +167115,17 @@ var ts;
|
|
|
166834
167115
|
// file's script kind, i.e. in one project some file is treated as ".ts"
|
|
166835
167116
|
// and in another as ".js"
|
|
166836
167117
|
if (scriptKind === oldSourceFile.scriptKind) {
|
|
166837
|
-
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167118
|
+
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
166838
167119
|
}
|
|
166839
167120
|
else {
|
|
166840
167121
|
// Release old source file and fall through to aquire new file with new script kind
|
|
166841
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
|
|
167122
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
166842
167123
|
}
|
|
166843
167124
|
}
|
|
166844
167125
|
// We didn't already have the file. Fall through and acquire it from the registry.
|
|
166845
167126
|
}
|
|
166846
167127
|
// Could not find this file in the old program, create a new SourceFile for it.
|
|
166847
|
-
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167128
|
+
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
166848
167129
|
}
|
|
166849
167130
|
}
|
|
166850
167131
|
// TODO: GH#18217 frequently asserted as defined
|
|
@@ -166923,7 +167204,7 @@ var ts;
|
|
|
166923
167204
|
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
|
|
166924
167205
|
var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
|
166925
167206
|
ts.forEach(program.getSourceFiles(), function (f) {
|
|
166926
|
-
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind);
|
|
167207
|
+
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat);
|
|
166927
167208
|
});
|
|
166928
167209
|
program = undefined; // TODO: GH#18217
|
|
166929
167210
|
}
|
|
@@ -167840,6 +168121,7 @@ var ts;
|
|
|
167840
168121
|
getEmitOutput: getEmitOutput,
|
|
167841
168122
|
getNonBoundSourceFile: getNonBoundSourceFile,
|
|
167842
168123
|
getProgram: getProgram,
|
|
168124
|
+
getCurrentProgram: function () { return program; },
|
|
167843
168125
|
getAutoImportProvider: getAutoImportProvider,
|
|
167844
168126
|
updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
|
|
167845
168127
|
getApplicableRefactors: getApplicableRefactors,
|
|
@@ -171476,7 +171758,7 @@ var ts;
|
|
|
171476
171758
|
};
|
|
171477
171759
|
/*@internal*/
|
|
171478
171760
|
Project.prototype.watchAffectingFileLocation = function (file, cb) {
|
|
171479
|
-
return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.
|
|
171761
|
+
return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.AffectingFileLocation, this);
|
|
171480
171762
|
};
|
|
171481
171763
|
/*@internal*/
|
|
171482
171764
|
Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () {
|
|
@@ -172013,7 +172295,7 @@ var ts;
|
|
|
172013
172295
|
};
|
|
172014
172296
|
Project.prototype.updateGraphWorker = function () {
|
|
172015
172297
|
var _this = this;
|
|
172016
|
-
var oldProgram = this.
|
|
172298
|
+
var oldProgram = this.languageService.getCurrentProgram();
|
|
172017
172299
|
ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
|
|
172018
172300
|
this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName());
|
|
172019
172301
|
var start = ts.timestamp();
|
|
@@ -172022,7 +172304,7 @@ var ts;
|
|
|
172022
172304
|
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
|
172023
172305
|
this.dirty = false;
|
|
172024
172306
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
|
|
172025
|
-
this.resolutionCache.finishCachingPerDirectoryResolution();
|
|
172307
|
+
this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram);
|
|
172026
172308
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
172027
172309
|
ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
|
|
172028
172310
|
// bump up the version if
|
|
@@ -174480,7 +174762,7 @@ var ts;
|
|
|
174480
174762
|
// created when any of the script infos are added as root of inferred project
|
|
174481
174763
|
if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) {
|
|
174482
174764
|
// If we cannot watch config file existence without configured project, close the configured file watcher
|
|
174483
|
-
if (!ts.
|
|
174765
|
+
if (!ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath))) {
|
|
174484
174766
|
configFileExistenceInfo.watcher.close();
|
|
174485
174767
|
configFileExistenceInfo.watcher = noopConfigFileWatcher;
|
|
174486
174768
|
}
|
|
@@ -174560,7 +174842,7 @@ var ts;
|
|
|
174560
174842
|
// Set this file as the root of inferred project
|
|
174561
174843
|
(configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, true);
|
|
174562
174844
|
// If there is no configured project for this config file, add the file watcher
|
|
174563
|
-
configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.
|
|
174845
|
+
configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath)) ?
|
|
174564
174846
|
_this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) :
|
|
174565
174847
|
noopConfigFileWatcher);
|
|
174566
174848
|
});
|