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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220804";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8756,6 +8756,10 @@ var ts;
|
|
|
8756
8756
|
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."),
|
|
8757
8757
|
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`."),
|
|
8758
8758
|
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 '**/*'"),
|
|
8759
|
+
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\""),
|
|
8760
|
+
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\""),
|
|
8761
|
+
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\""),
|
|
8762
|
+
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"),
|
|
8759
8763
|
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."),
|
|
8760
8764
|
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."),
|
|
8761
8765
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -22059,7 +22063,7 @@ var ts;
|
|
|
22059
22063
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
22060
22064
|
* property or element access.
|
|
22061
22065
|
*/
|
|
22062
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
22066
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
22063
22067
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
22064
22068
|
// to parenthesize the expression before a dot. The known exception is:
|
|
22065
22069
|
//
|
|
@@ -22068,7 +22072,8 @@ var ts;
|
|
|
22068
22072
|
//
|
|
22069
22073
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
22070
22074
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
22071
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22075
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22076
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
22072
22077
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
22073
22078
|
return expression;
|
|
22074
22079
|
}
|
|
@@ -23475,7 +23480,7 @@ var ts;
|
|
|
23475
23480
|
// @api
|
|
23476
23481
|
function createDecorator(expression) {
|
|
23477
23482
|
var node = createBaseNode(165 /* Decorator */);
|
|
23478
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23483
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23479
23484
|
node.transformFlags |=
|
|
23480
23485
|
propagateChildFlags(node.expression) |
|
|
23481
23486
|
1 /* ContainsTypeScript */ |
|
|
@@ -24276,7 +24281,7 @@ var ts;
|
|
|
24276
24281
|
// @api
|
|
24277
24282
|
function createPropertyAccessExpression(expression, name) {
|
|
24278
24283
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24279
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24284
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24280
24285
|
node.name = asName(name);
|
|
24281
24286
|
node.transformFlags =
|
|
24282
24287
|
propagateChildFlags(node.expression) |
|
|
@@ -24306,7 +24311,7 @@ var ts;
|
|
|
24306
24311
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24307
24312
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24308
24313
|
node.flags |= 32 /* OptionalChain */;
|
|
24309
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24314
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24310
24315
|
node.questionDotToken = questionDotToken;
|
|
24311
24316
|
node.name = asName(name);
|
|
24312
24317
|
node.transformFlags |=
|
|
@@ -24332,7 +24337,7 @@ var ts;
|
|
|
24332
24337
|
// @api
|
|
24333
24338
|
function createElementAccessExpression(expression, index) {
|
|
24334
24339
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24335
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24340
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24336
24341
|
node.argumentExpression = asExpression(index);
|
|
24337
24342
|
node.transformFlags |=
|
|
24338
24343
|
propagateChildFlags(node.expression) |
|
|
@@ -24360,7 +24365,7 @@ var ts;
|
|
|
24360
24365
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24361
24366
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24362
24367
|
node.flags |= 32 /* OptionalChain */;
|
|
24363
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24368
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24364
24369
|
node.questionDotToken = questionDotToken;
|
|
24365
24370
|
node.argumentExpression = asExpression(index);
|
|
24366
24371
|
node.transformFlags |=
|
|
@@ -24384,7 +24389,7 @@ var ts;
|
|
|
24384
24389
|
// @api
|
|
24385
24390
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24386
24391
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24387
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24392
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24388
24393
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24389
24394
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24390
24395
|
node.transformFlags |=
|
|
@@ -24417,7 +24422,7 @@ var ts;
|
|
|
24417
24422
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24418
24423
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24419
24424
|
node.flags |= 32 /* OptionalChain */;
|
|
24420
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24425
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24421
24426
|
node.questionDotToken = questionDotToken;
|
|
24422
24427
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24423
24428
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24472,7 +24477,7 @@ var ts;
|
|
|
24472
24477
|
// @api
|
|
24473
24478
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24474
24479
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24475
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24480
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24476
24481
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24477
24482
|
node.template = template;
|
|
24478
24483
|
node.transformFlags |=
|
|
@@ -24910,7 +24915,7 @@ var ts;
|
|
|
24910
24915
|
// @api
|
|
24911
24916
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24912
24917
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24913
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24918
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24914
24919
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24915
24920
|
node.transformFlags |=
|
|
24916
24921
|
propagateChildFlags(node.expression) |
|
|
@@ -24946,7 +24951,7 @@ var ts;
|
|
|
24946
24951
|
// @api
|
|
24947
24952
|
function createNonNullExpression(expression) {
|
|
24948
24953
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24949
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24954
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24950
24955
|
node.transformFlags |=
|
|
24951
24956
|
propagateChildFlags(node.expression) |
|
|
24952
24957
|
1 /* ContainsTypeScript */;
|
|
@@ -24965,7 +24970,7 @@ var ts;
|
|
|
24965
24970
|
function createNonNullChain(expression) {
|
|
24966
24971
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24967
24972
|
node.flags |= 32 /* OptionalChain */;
|
|
24968
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24973
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24969
24974
|
node.transformFlags |=
|
|
24970
24975
|
propagateChildFlags(node.expression) |
|
|
24971
24976
|
1 /* ContainsTypeScript */;
|
|
@@ -27169,7 +27174,7 @@ var ts;
|
|
|
27169
27174
|
}
|
|
27170
27175
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
27171
27176
|
thisArg = createVoidZero();
|
|
27172
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
27177
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
27173
27178
|
}
|
|
27174
27179
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
27175
27180
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -27198,7 +27203,7 @@ var ts;
|
|
|
27198
27203
|
else {
|
|
27199
27204
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
27200
27205
|
thisArg = createVoidZero();
|
|
27201
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27206
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27202
27207
|
}
|
|
27203
27208
|
return { target: target, thisArg: thisArg };
|
|
27204
27209
|
}
|
|
@@ -43433,7 +43438,7 @@ var ts;
|
|
|
43433
43438
|
ts.createCacheWithRedirects = createCacheWithRedirects;
|
|
43434
43439
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
43435
43440
|
var cache;
|
|
43436
|
-
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
|
|
43441
|
+
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
|
|
43437
43442
|
function getPackageJsonInfo(packageJsonPath) {
|
|
43438
43443
|
return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
|
|
43439
43444
|
}
|
|
@@ -43447,6 +43452,9 @@ var ts;
|
|
|
43447
43452
|
var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
|
|
43448
43453
|
return iter ? ts.arrayFrom(iter) : [];
|
|
43449
43454
|
}
|
|
43455
|
+
function getInternalMap() {
|
|
43456
|
+
return cache;
|
|
43457
|
+
}
|
|
43450
43458
|
}
|
|
43451
43459
|
function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
|
|
43452
43460
|
var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
@@ -43550,15 +43558,18 @@ var ts;
|
|
|
43550
43558
|
}
|
|
43551
43559
|
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
43552
43560
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
43553
|
-
var
|
|
43561
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43554
43562
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
43555
43563
|
var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
43556
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43564
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43557
43565
|
function clear() {
|
|
43558
|
-
|
|
43559
|
-
moduleNameToDirectoryMap.clear();
|
|
43566
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43560
43567
|
packageJsonInfoCache.clear();
|
|
43561
43568
|
}
|
|
43569
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43570
|
+
perDirectoryResolutionCache.clear();
|
|
43571
|
+
moduleNameToDirectoryMap.clear();
|
|
43572
|
+
}
|
|
43562
43573
|
function update(options) {
|
|
43563
43574
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
43564
43575
|
}
|
|
@@ -43634,13 +43645,16 @@ var ts;
|
|
|
43634
43645
|
}
|
|
43635
43646
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
43636
43647
|
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
|
|
43637
|
-
var
|
|
43648
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43638
43649
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
43639
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43650
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43640
43651
|
function clear() {
|
|
43641
|
-
|
|
43652
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43642
43653
|
packageJsonInfoCache.clear();
|
|
43643
43654
|
}
|
|
43655
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43656
|
+
perDirectoryResolutionCache.clear();
|
|
43657
|
+
}
|
|
43644
43658
|
}
|
|
43645
43659
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
43646
43660
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
@@ -51428,10 +51442,6 @@ var ts;
|
|
|
51428
51442
|
checkExpressionCached(expression);
|
|
51429
51443
|
return getNodeLinks(expression).resolvedSymbol;
|
|
51430
51444
|
}
|
|
51431
|
-
function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
|
|
51432
|
-
var expression = node.initializer;
|
|
51433
|
-
return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
|
|
51434
|
-
}
|
|
51435
51445
|
function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
|
|
51436
51446
|
if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
|
|
51437
51447
|
return undefined;
|
|
@@ -51463,7 +51473,7 @@ var ts;
|
|
|
51463
51473
|
case 297 /* ShorthandPropertyAssignment */:
|
|
51464
51474
|
return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
|
|
51465
51475
|
case 296 /* PropertyAssignment */:
|
|
51466
|
-
return
|
|
51476
|
+
return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
|
|
51467
51477
|
case 207 /* ElementAccessExpression */:
|
|
51468
51478
|
case 206 /* PropertyAccessExpression */:
|
|
51469
51479
|
return getTargetOfAccessExpression(node, dontRecursivelyResolve);
|
|
@@ -56988,7 +56998,7 @@ var ts;
|
|
|
56988
56998
|
(resolvedSymbol || symbol).exports.forEach(function (s, name) {
|
|
56989
56999
|
var _a;
|
|
56990
57000
|
var exportedMember = members_4.get(name);
|
|
56991
|
-
if (exportedMember && exportedMember !== s) {
|
|
57001
|
+
if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
|
|
56992
57002
|
if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
|
|
56993
57003
|
// If the member has an additional value-like declaration, union the types from the two declarations,
|
|
56994
57004
|
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
|
|
@@ -63480,6 +63490,7 @@ var ts;
|
|
|
63480
63490
|
}
|
|
63481
63491
|
}
|
|
63482
63492
|
function getTypeFromImportTypeNode(node) {
|
|
63493
|
+
var _a;
|
|
63483
63494
|
var links = getNodeLinks(node);
|
|
63484
63495
|
if (!links.resolvedType) {
|
|
63485
63496
|
if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
|
|
@@ -63499,6 +63510,7 @@ var ts;
|
|
|
63499
63510
|
links.resolvedSymbol = unknownSymbol;
|
|
63500
63511
|
return links.resolvedType = errorType;
|
|
63501
63512
|
}
|
|
63513
|
+
var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
|
|
63502
63514
|
var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
|
|
63503
63515
|
if (!ts.nodeIsMissing(node.qualifier)) {
|
|
63504
63516
|
var nameStack = getIdentifierChain(node.qualifier);
|
|
@@ -63510,9 +63522,11 @@ var ts;
|
|
|
63510
63522
|
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
|
|
63511
63523
|
// the `exports` lookup process that only looks up namespace members which is used for most type references
|
|
63512
63524
|
var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
|
|
63513
|
-
var
|
|
63525
|
+
var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
|
|
63514
63526
|
? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
|
|
63515
|
-
:
|
|
63527
|
+
: undefined;
|
|
63528
|
+
var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
|
|
63529
|
+
var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
|
|
63516
63530
|
if (!next) {
|
|
63517
63531
|
error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
|
|
63518
63532
|
return links.resolvedType = errorType;
|
|
@@ -66370,6 +66384,26 @@ var ts;
|
|
|
66370
66384
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66371
66385
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66372
66386
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66387
|
+
if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
|
|
66388
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66389
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
66390
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66391
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66392
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66393
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66394
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66395
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66396
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
66397
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66398
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66399
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66400
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66401
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66402
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66403
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66404
|
+
result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66405
|
+
}
|
|
66406
|
+
}
|
|
66373
66407
|
if (result) {
|
|
66374
66408
|
resetErrorInfo(saveErrorInfo);
|
|
66375
66409
|
}
|
|
@@ -66427,28 +66461,6 @@ var ts;
|
|
|
66427
66461
|
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
66428
66462
|
return result;
|
|
66429
66463
|
}
|
|
66430
|
-
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
66431
|
-
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66432
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
66433
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66434
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66435
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66436
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66437
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66438
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66439
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
66440
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66441
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66442
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66443
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66444
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66445
|
-
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66446
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66447
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66448
|
-
return result;
|
|
66449
|
-
}
|
|
66450
|
-
}
|
|
66451
|
-
}
|
|
66452
66464
|
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
66453
66465
|
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
66454
66466
|
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
@@ -82302,9 +82314,11 @@ var ts;
|
|
|
82302
82314
|
// We only need `Awaited<T>` if `T` contains possibly non-primitive types.
|
|
82303
82315
|
if (isGenericObjectType(type)) {
|
|
82304
82316
|
var baseConstraint = getBaseConstraintOfType(type);
|
|
82305
|
-
// We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82317
|
+
// 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`,
|
|
82306
82318
|
// or is promise-like.
|
|
82307
|
-
if (
|
|
82319
|
+
if (baseConstraint ?
|
|
82320
|
+
baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
|
|
82321
|
+
maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
|
|
82308
82322
|
return true;
|
|
82309
82323
|
}
|
|
82310
82324
|
}
|
|
@@ -84181,17 +84195,28 @@ var ts;
|
|
|
84181
84195
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
84182
84196
|
*/
|
|
84183
84197
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84198
|
+
var _a, _b;
|
|
84184
84199
|
if (isTypeAny(type)) {
|
|
84185
84200
|
return anyIterationTypes;
|
|
84186
84201
|
}
|
|
84187
84202
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
84188
|
-
var
|
|
84203
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84204
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
84189
84205
|
if (iterationTypes_1 === noIterationTypes) {
|
|
84190
84206
|
if (errorNode) {
|
|
84191
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84207
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84208
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84209
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84210
|
+
}
|
|
84192
84211
|
}
|
|
84193
84212
|
return undefined;
|
|
84194
84213
|
}
|
|
84214
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84215
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84216
|
+
var diag = _c[_i];
|
|
84217
|
+
diagnostics.add(diag);
|
|
84218
|
+
}
|
|
84219
|
+
}
|
|
84195
84220
|
return iterationTypes_1;
|
|
84196
84221
|
}
|
|
84197
84222
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84199,19 +84224,27 @@ var ts;
|
|
|
84199
84224
|
if (cachedTypes)
|
|
84200
84225
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84201
84226
|
var allIterationTypes;
|
|
84202
|
-
for (var
|
|
84203
|
-
var constituent =
|
|
84204
|
-
var
|
|
84227
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84228
|
+
var constituent = _e[_d];
|
|
84229
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84230
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84205
84231
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84206
84232
|
if (errorNode) {
|
|
84207
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84233
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84234
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84235
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84236
|
+
}
|
|
84208
84237
|
}
|
|
84209
84238
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84210
84239
|
return undefined;
|
|
84211
84240
|
}
|
|
84212
|
-
else {
|
|
84213
|
-
|
|
84241
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84242
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84243
|
+
var diag = _g[_f];
|
|
84244
|
+
diagnostics.add(diag);
|
|
84245
|
+
}
|
|
84214
84246
|
}
|
|
84247
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84215
84248
|
}
|
|
84216
84249
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84217
84250
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84239,47 +84272,62 @@ var ts;
|
|
|
84239
84272
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84240
84273
|
* `getIterationTypesOfIterable` instead.
|
|
84241
84274
|
*/
|
|
84242
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84275
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84243
84276
|
if (isTypeAny(type)) {
|
|
84244
84277
|
return anyIterationTypes;
|
|
84245
84278
|
}
|
|
84279
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84280
|
+
// In addition, we should not cache any new results for this call.
|
|
84281
|
+
var noCache = false;
|
|
84246
84282
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84247
84283
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84248
84284
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84249
84285
|
if (iterationTypes) {
|
|
84250
|
-
|
|
84251
|
-
|
|
84252
|
-
|
|
84286
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84287
|
+
// ignore the cached value
|
|
84288
|
+
noCache = true;
|
|
84289
|
+
}
|
|
84290
|
+
else {
|
|
84291
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84292
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84293
|
+
iterationTypes;
|
|
84294
|
+
}
|
|
84253
84295
|
}
|
|
84254
84296
|
}
|
|
84255
84297
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84256
84298
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84257
84299
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84258
84300
|
if (iterationTypes) {
|
|
84259
|
-
if (
|
|
84260
|
-
//
|
|
84261
|
-
|
|
84262
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84263
|
-
}
|
|
84301
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84302
|
+
// ignore the cached value
|
|
84303
|
+
noCache = true;
|
|
84264
84304
|
}
|
|
84265
84305
|
else {
|
|
84266
|
-
|
|
84306
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84307
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84308
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84309
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84310
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84311
|
+
}
|
|
84312
|
+
}
|
|
84313
|
+
else {
|
|
84314
|
+
return iterationTypes;
|
|
84315
|
+
}
|
|
84267
84316
|
}
|
|
84268
84317
|
}
|
|
84269
84318
|
}
|
|
84270
84319
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84271
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84320
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84272
84321
|
if (iterationTypes !== noIterationTypes) {
|
|
84273
84322
|
return iterationTypes;
|
|
84274
84323
|
}
|
|
84275
84324
|
}
|
|
84276
84325
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84277
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84326
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84278
84327
|
if (iterationTypes !== noIterationTypes) {
|
|
84279
84328
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84280
|
-
|
|
84281
|
-
|
|
84282
|
-
: noIterationTypes);
|
|
84329
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84330
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84283
84331
|
}
|
|
84284
84332
|
else {
|
|
84285
84333
|
return iterationTypes;
|
|
@@ -84300,7 +84348,7 @@ var ts;
|
|
|
84300
84348
|
}
|
|
84301
84349
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84302
84350
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84303
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84351
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84304
84352
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84305
84353
|
}
|
|
84306
84354
|
/**
|
|
@@ -84354,26 +84402,26 @@ var ts;
|
|
|
84354
84402
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84355
84403
|
* `getIterationTypesOfIterable` instead.
|
|
84356
84404
|
*/
|
|
84357
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84405
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84358
84406
|
var _a;
|
|
84359
84407
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84360
84408
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84361
84409
|
if (isTypeAny(methodType)) {
|
|
84362
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84410
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84363
84411
|
}
|
|
84364
84412
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84365
84413
|
if (!ts.some(signatures)) {
|
|
84366
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84414
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84367
84415
|
}
|
|
84368
84416
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84369
|
-
var iterationTypes = (_a =
|
|
84370
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84417
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84418
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84371
84419
|
}
|
|
84372
84420
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84373
84421
|
var message = allowAsyncIterables
|
|
84374
84422
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84375
84423
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84376
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84424
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84377
84425
|
}
|
|
84378
84426
|
/**
|
|
84379
84427
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -84381,13 +84429,29 @@ var ts;
|
|
|
84381
84429
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84382
84430
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84383
84431
|
*/
|
|
84384
|
-
function getIterationTypesOfIterator(type, resolver, errorNode) {
|
|
84432
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84433
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84434
|
+
}
|
|
84435
|
+
/**
|
|
84436
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84437
|
+
*
|
|
84438
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84439
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84440
|
+
*
|
|
84441
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84442
|
+
* `getIterationTypesOfIterator` instead.
|
|
84443
|
+
*/
|
|
84444
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84385
84445
|
if (isTypeAny(type)) {
|
|
84386
84446
|
return anyIterationTypes;
|
|
84387
84447
|
}
|
|
84388
84448
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84389
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84390
|
-
|
|
84449
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84450
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84451
|
+
iterationTypes = undefined;
|
|
84452
|
+
noCache = true;
|
|
84453
|
+
}
|
|
84454
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84391
84455
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84392
84456
|
}
|
|
84393
84457
|
/**
|
|
@@ -84425,7 +84489,7 @@ var ts;
|
|
|
84425
84489
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84426
84490
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84427
84491
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84428
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84492
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84429
84493
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84430
84494
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84431
84495
|
}
|
|
@@ -84495,8 +84559,8 @@ var ts;
|
|
|
84495
84559
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84496
84560
|
* record is returned. Otherwise, we return `undefined`.
|
|
84497
84561
|
*/
|
|
84498
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84499
|
-
var _a, _b, _c, _d;
|
|
84562
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84563
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84500
84564
|
var method = getPropertyOfType(type, methodName);
|
|
84501
84565
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84502
84566
|
if (!method && methodName !== "next") {
|
|
@@ -84516,9 +84580,15 @@ var ts;
|
|
|
84516
84580
|
var diagnostic = methodName === "next"
|
|
84517
84581
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84518
84582
|
: resolver.mustBeAMethodDiagnostic;
|
|
84519
|
-
|
|
84583
|
+
if (errorOutputContainer) {
|
|
84584
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84585
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84586
|
+
}
|
|
84587
|
+
else {
|
|
84588
|
+
error(errorNode, diagnostic, methodName);
|
|
84589
|
+
}
|
|
84520
84590
|
}
|
|
84521
|
-
return methodName === "next" ?
|
|
84591
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84522
84592
|
}
|
|
84523
84593
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84524
84594
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84530,8 +84600,8 @@ var ts;
|
|
|
84530
84600
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84531
84601
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84532
84602
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84533
|
-
var isGeneratorMethod = ((
|
|
84534
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84603
|
+
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;
|
|
84604
|
+
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;
|
|
84535
84605
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84536
84606
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84537
84607
|
var mapper = methodType.mapper;
|
|
@@ -84571,7 +84641,13 @@ var ts;
|
|
|
84571
84641
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84572
84642
|
if (iterationTypes === noIterationTypes) {
|
|
84573
84643
|
if (errorNode) {
|
|
84574
|
-
|
|
84644
|
+
if (errorOutputContainer) {
|
|
84645
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84646
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84647
|
+
}
|
|
84648
|
+
else {
|
|
84649
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84650
|
+
}
|
|
84575
84651
|
}
|
|
84576
84652
|
yieldType = anyType;
|
|
84577
84653
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84592,13 +84668,13 @@ var ts;
|
|
|
84592
84668
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84593
84669
|
* `getIterationTypesOfIterator` instead.
|
|
84594
84670
|
*/
|
|
84595
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84671
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84596
84672
|
var iterationTypes = combineIterationTypes([
|
|
84597
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84598
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84599
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84673
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84674
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84675
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84600
84676
|
]);
|
|
84601
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84677
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84602
84678
|
}
|
|
84603
84679
|
/**
|
|
84604
84680
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84619,7 +84695,7 @@ var ts;
|
|
|
84619
84695
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84620
84696
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84621
84697
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84622
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84698
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84623
84699
|
}
|
|
84624
84700
|
function checkBreakOrContinueStatement(node) {
|
|
84625
84701
|
// Grammar checking
|
|
@@ -95076,10 +95152,11 @@ var ts;
|
|
|
95076
95152
|
}
|
|
95077
95153
|
function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
|
|
95078
95154
|
if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
|
|
95079
|
-
|
|
95155
|
+
var operand = ts.skipParentheses(node.operand);
|
|
95156
|
+
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
|
|
95080
95157
|
var info = void 0;
|
|
95081
|
-
if (info = accessPrivateIdentifier(
|
|
95082
|
-
var receiver = ts.visitNode(
|
|
95158
|
+
if (info = accessPrivateIdentifier(operand.name)) {
|
|
95159
|
+
var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
|
|
95083
95160
|
var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
|
|
95084
95161
|
var expression = createPrivateIdentifierAccess(info, readExpression);
|
|
95085
95162
|
var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
@@ -95095,7 +95172,7 @@ var ts;
|
|
|
95095
95172
|
}
|
|
95096
95173
|
}
|
|
95097
95174
|
else if (shouldTransformSuperInStaticInitializers &&
|
|
95098
|
-
ts.isSuperProperty(
|
|
95175
|
+
ts.isSuperProperty(operand) &&
|
|
95099
95176
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
95100
95177
|
currentClassLexicalEnvironment) {
|
|
95101
95178
|
// converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
|
|
@@ -95108,31 +95185,31 @@ var ts;
|
|
|
95108
95185
|
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
|
|
95109
95186
|
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
|
|
95110
95187
|
if (facts & 1 /* ClassWasDecorated */) {
|
|
95111
|
-
var
|
|
95188
|
+
var expression = visitInvalidSuperProperty(operand);
|
|
95112
95189
|
return ts.isPrefixUnaryExpression(node) ?
|
|
95113
|
-
factory.updatePrefixUnaryExpression(node,
|
|
95114
|
-
factory.updatePostfixUnaryExpression(node,
|
|
95190
|
+
factory.updatePrefixUnaryExpression(node, expression) :
|
|
95191
|
+
factory.updatePostfixUnaryExpression(node, expression);
|
|
95115
95192
|
}
|
|
95116
95193
|
if (classConstructor && superClassReference) {
|
|
95117
95194
|
var setterName = void 0;
|
|
95118
95195
|
var getterName = void 0;
|
|
95119
|
-
if (ts.isPropertyAccessExpression(
|
|
95120
|
-
if (ts.isIdentifier(
|
|
95121
|
-
getterName = setterName = factory.createStringLiteralFromNode(
|
|
95196
|
+
if (ts.isPropertyAccessExpression(operand)) {
|
|
95197
|
+
if (ts.isIdentifier(operand.name)) {
|
|
95198
|
+
getterName = setterName = factory.createStringLiteralFromNode(operand.name);
|
|
95122
95199
|
}
|
|
95123
95200
|
}
|
|
95124
95201
|
else {
|
|
95125
|
-
if (ts.isSimpleInlineableExpression(
|
|
95126
|
-
getterName = setterName =
|
|
95202
|
+
if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
|
|
95203
|
+
getterName = setterName = operand.argumentExpression;
|
|
95127
95204
|
}
|
|
95128
95205
|
else {
|
|
95129
95206
|
getterName = factory.createTempVariable(hoistVariableDeclaration);
|
|
95130
|
-
setterName = factory.createAssignment(getterName, ts.visitNode(
|
|
95207
|
+
setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
|
|
95131
95208
|
}
|
|
95132
95209
|
}
|
|
95133
95210
|
if (setterName && getterName) {
|
|
95134
95211
|
var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
|
|
95135
|
-
ts.setTextRange(expression,
|
|
95212
|
+
ts.setTextRange(expression, operand);
|
|
95136
95213
|
var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
95137
95214
|
expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
|
|
95138
95215
|
expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
|
|
@@ -117887,6 +117964,12 @@ var ts;
|
|
|
117887
117964
|
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
117888
117965
|
*/
|
|
117889
117966
|
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
117967
|
+
var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
|
117968
|
+
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
117969
|
+
}
|
|
117970
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
117971
|
+
/*@internal*/
|
|
117972
|
+
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
117890
117973
|
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
117891
117974
|
case ts.ModuleResolutionKind.Node16:
|
|
117892
117975
|
case ts.ModuleResolutionKind.NodeNext:
|
|
@@ -117898,11 +117981,16 @@ var ts;
|
|
|
117898
117981
|
return undefined;
|
|
117899
117982
|
}
|
|
117900
117983
|
function lookupFromPackageJson() {
|
|
117901
|
-
var
|
|
117902
|
-
|
|
117984
|
+
var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
117985
|
+
var packageJsonLocations = [];
|
|
117986
|
+
state.failedLookupLocations = packageJsonLocations;
|
|
117987
|
+
state.affectingLocations = packageJsonLocations;
|
|
117988
|
+
var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
|
|
117989
|
+
var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
117990
|
+
return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
|
|
117903
117991
|
}
|
|
117904
117992
|
}
|
|
117905
|
-
ts.
|
|
117993
|
+
ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
|
|
117906
117994
|
/** @internal */
|
|
117907
117995
|
ts.plainJSErrors = new ts.Set([
|
|
117908
117996
|
// binder errors
|
|
@@ -118227,7 +118315,7 @@ var ts;
|
|
|
118227
118315
|
for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
|
|
118228
118316
|
var oldSourceFile = oldSourceFiles_1[_i];
|
|
118229
118317
|
var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
|
118230
|
-
if (shouldCreateNewSourceFile || !newFile ||
|
|
118318
|
+
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
118231
118319
|
// old file wasn't redirect but new file is
|
|
118232
118320
|
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
|
118233
118321
|
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
|
@@ -118620,7 +118708,7 @@ var ts;
|
|
|
118620
118708
|
});
|
|
118621
118709
|
}
|
|
118622
118710
|
function tryReuseStructureFromOldProgram() {
|
|
118623
|
-
var _a;
|
|
118711
|
+
var _a, _b;
|
|
118624
118712
|
if (!oldProgram) {
|
|
118625
118713
|
return 0 /* Not */;
|
|
118626
118714
|
}
|
|
@@ -118661,12 +118749,15 @@ var ts;
|
|
|
118661
118749
|
var seenPackageNames = new ts.Map();
|
|
118662
118750
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
118663
118751
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
118752
|
+
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
118664
118753
|
var newSourceFile = host.getSourceFileByPath
|
|
118665
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath,
|
|
118666
|
-
: host.getSourceFile(oldSourceFile.fileName,
|
|
118754
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
|
118755
|
+
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
|
118667
118756
|
if (!newSourceFile) {
|
|
118668
118757
|
return 0 /* Not */;
|
|
118669
118758
|
}
|
|
118759
|
+
newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
118760
|
+
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
118670
118761
|
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
|
118671
118762
|
var fileChanged = void 0;
|
|
118672
118763
|
if (oldSourceFile.redirectInfo) {
|
|
@@ -118706,38 +118797,43 @@ var ts;
|
|
|
118706
118797
|
seenPackageNames.set(packageName, newKind);
|
|
118707
118798
|
}
|
|
118708
118799
|
if (fileChanged) {
|
|
118800
|
+
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
|
118801
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118802
|
+
}
|
|
118709
118803
|
// The `newSourceFile` object was created for the new program.
|
|
118710
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118804
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118711
118805
|
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
|
118712
118806
|
structureIsReused = 1 /* SafeModules */;
|
|
118713
118807
|
}
|
|
118714
|
-
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118808
|
+
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118715
118809
|
// value of no-default-lib has changed
|
|
118716
118810
|
// this will affect if default library is injected into the list of files
|
|
118717
118811
|
structureIsReused = 1 /* SafeModules */;
|
|
118718
118812
|
}
|
|
118719
118813
|
// check tripleslash references
|
|
118720
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118814
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118721
118815
|
// tripleslash references has changed
|
|
118722
118816
|
structureIsReused = 1 /* SafeModules */;
|
|
118723
118817
|
}
|
|
118724
|
-
|
|
118725
|
-
|
|
118726
|
-
|
|
118727
|
-
|
|
118728
|
-
|
|
118729
|
-
|
|
118730
|
-
|
|
118731
|
-
|
|
118732
|
-
|
|
118733
|
-
|
|
118734
|
-
|
|
118735
|
-
|
|
118736
|
-
|
|
118737
|
-
|
|
118738
|
-
|
|
118739
|
-
|
|
118740
|
-
|
|
118818
|
+
else {
|
|
118819
|
+
// check imports and module augmentations
|
|
118820
|
+
collectExternalModuleReferences(newSourceFile);
|
|
118821
|
+
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
|
118822
|
+
// imports has changed
|
|
118823
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118824
|
+
}
|
|
118825
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
|
118826
|
+
// moduleAugmentations has changed
|
|
118827
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118828
|
+
}
|
|
118829
|
+
else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
118830
|
+
// dynamicImport has changed
|
|
118831
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118832
|
+
}
|
|
118833
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118834
|
+
// 'types' references has changed
|
|
118835
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118836
|
+
}
|
|
118741
118837
|
}
|
|
118742
118838
|
// tentatively approve the file
|
|
118743
118839
|
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
|
@@ -118755,18 +118851,18 @@ var ts;
|
|
|
118755
118851
|
return structureIsReused;
|
|
118756
118852
|
}
|
|
118757
118853
|
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
|
|
118758
|
-
for (var
|
|
118759
|
-
var oldFile = oldSourceFiles_3[
|
|
118854
|
+
for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
|
|
118855
|
+
var oldFile = oldSourceFiles_3[_c];
|
|
118760
118856
|
if (!ts.contains(modifiedFiles, oldFile)) {
|
|
118761
|
-
for (var
|
|
118762
|
-
var moduleName = _d
|
|
118857
|
+
for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
|
|
118858
|
+
var moduleName = _e[_d];
|
|
118763
118859
|
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
118764
118860
|
}
|
|
118765
118861
|
}
|
|
118766
118862
|
}
|
|
118767
118863
|
// try to verify results of module resolution
|
|
118768
|
-
for (var
|
|
118769
|
-
var
|
|
118864
|
+
for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
|
|
118865
|
+
var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
|
|
118770
118866
|
var moduleNames = getModuleNames(newSourceFile);
|
|
118771
118867
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
118772
118868
|
// ensure that module resolution results are still correct
|
|
@@ -118793,14 +118889,14 @@ var ts;
|
|
|
118793
118889
|
if (structureIsReused !== 2 /* Completely */) {
|
|
118794
118890
|
return structureIsReused;
|
|
118795
118891
|
}
|
|
118796
|
-
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((
|
|
118892
|
+
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
|
|
118797
118893
|
return 1 /* SafeModules */;
|
|
118798
118894
|
}
|
|
118799
118895
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
118800
118896
|
// update fileName -> file mapping
|
|
118801
118897
|
ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
118802
|
-
for (var
|
|
118803
|
-
var newSourceFile = newSourceFiles_1[
|
|
118898
|
+
for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
|
|
118899
|
+
var newSourceFile = newSourceFiles_1[_h];
|
|
118804
118900
|
filesByName.set(newSourceFile.path, newSourceFile);
|
|
118805
118901
|
}
|
|
118806
118902
|
var oldFilesByNameMap = oldProgram.getFilesByNameMap();
|
|
@@ -119583,13 +119679,16 @@ var ts;
|
|
|
119583
119679
|
addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
|
|
119584
119680
|
}
|
|
119585
119681
|
}
|
|
119586
|
-
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
|
|
119682
|
+
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
|
|
119683
|
+
var _a;
|
|
119587
119684
|
var redirect = Object.create(redirectTarget);
|
|
119588
119685
|
redirect.fileName = fileName;
|
|
119589
119686
|
redirect.path = path;
|
|
119590
119687
|
redirect.resolvedPath = resolvedPath;
|
|
119591
119688
|
redirect.originalFileName = originalFileName;
|
|
119592
119689
|
redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
|
|
119690
|
+
redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119691
|
+
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119593
119692
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
119594
119693
|
Object.defineProperties(redirect, {
|
|
119595
119694
|
id: {
|
|
@@ -119618,14 +119717,14 @@ var ts;
|
|
|
119618
119717
|
// 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
|
|
119619
119718
|
// 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
|
|
119620
119719
|
// 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.
|
|
119621
|
-
var
|
|
119622
|
-
|
|
119623
|
-
|
|
119624
|
-
|
|
119625
|
-
setExternalModuleIndicator:
|
|
119626
|
-
};
|
|
119720
|
+
var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
119721
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
119722
|
+
var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
|
|
119723
|
+
return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
|
|
119724
|
+
{ languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
|
|
119627
119725
|
}
|
|
119628
119726
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
119727
|
+
var _a, _b;
|
|
119629
119728
|
var path = toPath(fileName);
|
|
119630
119729
|
if (useSourceOfProjectReferenceRedirect) {
|
|
119631
119730
|
var source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -119712,14 +119811,15 @@ var ts;
|
|
|
119712
119811
|
}
|
|
119713
119812
|
}
|
|
119714
119813
|
// We haven't looked for this file, do so now and cache result
|
|
119715
|
-
var
|
|
119814
|
+
var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
119815
|
+
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));
|
|
119716
119816
|
if (packageId) {
|
|
119717
119817
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
119718
119818
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
119719
119819
|
if (fileFromPackageId) {
|
|
119720
119820
|
// Some other SourceFile already exists with this package name and version.
|
|
119721
119821
|
// Instead of creating a duplicate, just redirect to the existing one.
|
|
119722
|
-
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
|
|
119822
|
+
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
|
119723
119823
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
119724
119824
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
119725
119825
|
addFileIncludeReason(dupFile, reason);
|
|
@@ -119740,6 +119840,8 @@ var ts;
|
|
|
119740
119840
|
file.path = path;
|
|
119741
119841
|
file.resolvedPath = toPath(fileName);
|
|
119742
119842
|
file.originalFileName = originalFileName;
|
|
119843
|
+
file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119844
|
+
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119743
119845
|
addFileIncludeReason(file, reason);
|
|
119744
119846
|
if (host.useCaseSensitiveFileNames()) {
|
|
119745
119847
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -120370,7 +120472,7 @@ var ts;
|
|
|
120370
120472
|
fileIncludeReasons = undefined;
|
|
120371
120473
|
var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
|
|
120372
120474
|
var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
120373
|
-
var redirectInfo = file && ts.
|
|
120475
|
+
var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
|
|
120374
120476
|
var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
|
|
120375
120477
|
return location && isReferenceFileLocation(location) ?
|
|
120376
120478
|
ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
|
|
@@ -122675,7 +122777,7 @@ var ts;
|
|
|
122675
122777
|
* "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
|
|
122676
122778
|
* @param dirPath
|
|
122677
122779
|
*/
|
|
122678
|
-
function
|
|
122780
|
+
function canWatchDirectoryOrFile(dirPath) {
|
|
122679
122781
|
var rootLength = ts.getRootLength(dirPath);
|
|
122680
122782
|
if (dirPath.length === rootLength) {
|
|
122681
122783
|
// Ignore "/", "c:/"
|
|
@@ -122712,7 +122814,7 @@ var ts;
|
|
|
122712
122814
|
}
|
|
122713
122815
|
return true;
|
|
122714
122816
|
}
|
|
122715
|
-
ts.
|
|
122817
|
+
ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
|
|
122716
122818
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
122717
122819
|
var filesWithChangedSetOfUnresolvedImports;
|
|
122718
122820
|
var filesWithInvalidatedResolutions;
|
|
@@ -122721,7 +122823,9 @@ var ts;
|
|
|
122721
122823
|
var resolutionsWithFailedLookups = [];
|
|
122722
122824
|
var resolutionsWithOnlyAffectingLocations = [];
|
|
122723
122825
|
var resolvedFileToResolution = ts.createMultiMap();
|
|
122826
|
+
var impliedFormatPackageJsons = new ts.Map();
|
|
122724
122827
|
var hasChangedAutomaticTypeDirectiveNames = false;
|
|
122828
|
+
var affectingPathChecksForFile;
|
|
122725
122829
|
var affectingPathChecks;
|
|
122726
122830
|
var failedLookupChecks;
|
|
122727
122831
|
var startsWithPathChecks;
|
|
@@ -122761,7 +122865,7 @@ var ts;
|
|
|
122761
122865
|
finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
|
|
122762
122866
|
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122763
122867
|
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122764
|
-
startCachingPerDirectoryResolution:
|
|
122868
|
+
startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
|
|
122765
122869
|
finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
|
|
122766
122870
|
resolveModuleNames: resolveModuleNames,
|
|
122767
122871
|
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
@@ -122805,9 +122909,10 @@ var ts;
|
|
|
122805
122909
|
startsWithPathChecks = undefined;
|
|
122806
122910
|
isInDirectoryChecks = undefined;
|
|
122807
122911
|
affectingPathChecks = undefined;
|
|
122808
|
-
|
|
122809
|
-
|
|
122810
|
-
|
|
122912
|
+
affectingPathChecksForFile = undefined;
|
|
122913
|
+
moduleResolutionCache.clear();
|
|
122914
|
+
typeReferenceDirectiveResolutionCache.clear();
|
|
122915
|
+
impliedFormatPackageJsons.clear();
|
|
122811
122916
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122812
122917
|
}
|
|
122813
122918
|
function startRecordingFilesWithChangedResolutions() {
|
|
@@ -122839,15 +122944,44 @@ var ts;
|
|
|
122839
122944
|
return function (path) { return (!!collected && collected.has(path)) ||
|
|
122840
122945
|
isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
|
|
122841
122946
|
}
|
|
122842
|
-
function
|
|
122843
|
-
moduleResolutionCache.
|
|
122844
|
-
typeReferenceDirectiveResolutionCache.
|
|
122947
|
+
function startCachingPerDirectoryResolution() {
|
|
122948
|
+
moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122949
|
+
typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122950
|
+
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122951
|
+
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122845
122952
|
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122846
122953
|
nonRelativeExternalModuleResolutions.clear();
|
|
122847
122954
|
}
|
|
122848
|
-
function finishCachingPerDirectoryResolution() {
|
|
122955
|
+
function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
|
|
122849
122956
|
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
|
122850
|
-
|
|
122957
|
+
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122958
|
+
nonRelativeExternalModuleResolutions.clear();
|
|
122959
|
+
// Update file watches
|
|
122960
|
+
if (newProgram !== oldProgram) {
|
|
122961
|
+
newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
|
|
122962
|
+
var _a, _b, _c;
|
|
122963
|
+
var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
122964
|
+
var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
|
|
122965
|
+
for (var i = existing.length; i < expected; i++) {
|
|
122966
|
+
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
|
|
122967
|
+
}
|
|
122968
|
+
if (existing.length > expected) {
|
|
122969
|
+
for (var i = expected; i < existing.length; i++) {
|
|
122970
|
+
fileWatchesOfAffectingLocations.get(existing[i]).files--;
|
|
122971
|
+
}
|
|
122972
|
+
}
|
|
122973
|
+
if (expected)
|
|
122974
|
+
impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
|
|
122975
|
+
else
|
|
122976
|
+
impliedFormatPackageJsons.delete(newFile.path);
|
|
122977
|
+
});
|
|
122978
|
+
impliedFormatPackageJsons.forEach(function (existing, path) {
|
|
122979
|
+
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
122980
|
+
existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
|
|
122981
|
+
impliedFormatPackageJsons.delete(path);
|
|
122982
|
+
}
|
|
122983
|
+
});
|
|
122984
|
+
}
|
|
122851
122985
|
directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
|
|
122852
122986
|
if (watcher.refCount === 0) {
|
|
122853
122987
|
directoryWatchesOfFailedLookups.delete(path);
|
|
@@ -122855,11 +122989,9 @@ var ts;
|
|
|
122855
122989
|
}
|
|
122856
122990
|
});
|
|
122857
122991
|
fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
|
|
122858
|
-
if (watcher.
|
|
122992
|
+
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122859
122993
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122860
122994
|
watcher.watcher.close();
|
|
122861
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122862
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122863
122995
|
}
|
|
122864
122996
|
});
|
|
122865
122997
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -123086,7 +123218,7 @@ var ts;
|
|
|
123086
123218
|
}
|
|
123087
123219
|
// If the directory is node_modules use it to watch, always watch it recursively
|
|
123088
123220
|
if (ts.isNodeModulesDirectory(dirPath)) {
|
|
123089
|
-
return
|
|
123221
|
+
return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
|
|
123090
123222
|
}
|
|
123091
123223
|
var nonRecursive = true;
|
|
123092
123224
|
// Use some ancestor of the root directory
|
|
@@ -123104,7 +123236,7 @@ var ts;
|
|
|
123104
123236
|
dir = ts.getDirectoryPath(dir);
|
|
123105
123237
|
}
|
|
123106
123238
|
}
|
|
123107
|
-
return
|
|
123239
|
+
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
|
|
123108
123240
|
}
|
|
123109
123241
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
123110
123242
|
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
@@ -123175,46 +123307,65 @@ var ts;
|
|
|
123175
123307
|
// Watch package json
|
|
123176
123308
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
123177
123309
|
var affectingLocation = affectingLocations_1[_i];
|
|
123178
|
-
createFileWatcherOfAffectingLocation(affectingLocation);
|
|
123310
|
+
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
|
123179
123311
|
}
|
|
123180
123312
|
}
|
|
123181
|
-
function createFileWatcherOfAffectingLocation(affectingLocation) {
|
|
123182
|
-
var
|
|
123183
|
-
var fileWatcher = fileWatchesOfAffectingLocations.get(path);
|
|
123313
|
+
function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
|
|
123314
|
+
var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123184
123315
|
if (fileWatcher) {
|
|
123185
|
-
|
|
123316
|
+
if (forResolution)
|
|
123317
|
+
fileWatcher.resolutions++;
|
|
123318
|
+
else
|
|
123319
|
+
fileWatcher.files++;
|
|
123186
123320
|
return;
|
|
123187
123321
|
}
|
|
123188
123322
|
var locationToWatch = affectingLocation;
|
|
123189
|
-
var locationToWatchPath = path;
|
|
123190
123323
|
if (resolutionHost.realpath) {
|
|
123191
123324
|
locationToWatch = resolutionHost.realpath(affectingLocation);
|
|
123192
|
-
|
|
123193
|
-
|
|
123194
|
-
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
|
|
123325
|
+
if (affectingLocation !== locationToWatch) {
|
|
123326
|
+
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
|
|
123195
123327
|
if (fileWatcher_1) {
|
|
123196
|
-
|
|
123197
|
-
|
|
123198
|
-
|
|
123328
|
+
if (forResolution)
|
|
123329
|
+
fileWatcher_1.resolutions++;
|
|
123330
|
+
else
|
|
123331
|
+
fileWatcher_1.files++;
|
|
123332
|
+
fileWatcher_1.paths.add(affectingLocation);
|
|
123333
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
|
|
123199
123334
|
return;
|
|
123200
123335
|
}
|
|
123201
123336
|
}
|
|
123202
123337
|
}
|
|
123203
123338
|
var paths = new ts.Set();
|
|
123204
|
-
paths.add(
|
|
123205
|
-
var
|
|
123206
|
-
|
|
123207
|
-
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName,
|
|
123208
|
-
|
|
123339
|
+
paths.add(locationToWatch);
|
|
123340
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123341
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123342
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123343
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123344
|
+
paths.forEach(function (path) {
|
|
123345
|
+
if (watcher.resolutions)
|
|
123346
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123347
|
+
if (watcher.files)
|
|
123348
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123349
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123350
|
+
});
|
|
123209
123351
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123210
|
-
})
|
|
123211
|
-
|
|
123352
|
+
}) : ts.noopFileWatcher;
|
|
123353
|
+
var watcher = {
|
|
123354
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123355
|
+
close: function () {
|
|
123356
|
+
actualWatcher.close();
|
|
123357
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123358
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123359
|
+
}
|
|
123360
|
+
} : actualWatcher,
|
|
123361
|
+
resolutions: forResolution ? 1 : 0,
|
|
123362
|
+
files: forResolution ? 0 : 1,
|
|
123212
123363
|
paths: paths,
|
|
123213
123364
|
};
|
|
123214
|
-
fileWatchesOfAffectingLocations.set(
|
|
123215
|
-
if (
|
|
123216
|
-
fileWatchesOfAffectingLocations.set(
|
|
123217
|
-
paths.add(
|
|
123365
|
+
fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
|
|
123366
|
+
if (affectingLocation !== locationToWatch) {
|
|
123367
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
|
|
123368
|
+
paths.add(affectingLocation);
|
|
123218
123369
|
}
|
|
123219
123370
|
}
|
|
123220
123371
|
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
|
|
@@ -123282,8 +123433,8 @@ var ts;
|
|
|
123282
123433
|
}
|
|
123283
123434
|
for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
|
|
123284
123435
|
var affectingLocation = affectingLocations_2[_a];
|
|
123285
|
-
var watcher = fileWatchesOfAffectingLocations.get(
|
|
123286
|
-
watcher.
|
|
123436
|
+
var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123437
|
+
watcher.resolutions--;
|
|
123287
123438
|
}
|
|
123288
123439
|
}
|
|
123289
123440
|
function removeDirectoryWatcher(dirPath) {
|
|
@@ -123337,7 +123488,7 @@ var ts;
|
|
|
123337
123488
|
resolution.isInvalidated = invalidated = true;
|
|
123338
123489
|
for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
|
|
123339
123490
|
var containingFilePath = _b[_a];
|
|
123340
|
-
(filesWithInvalidatedResolutions
|
|
123491
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
|
|
123341
123492
|
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
|
123342
123493
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
|
|
123343
123494
|
}
|
|
@@ -123404,10 +123555,25 @@ var ts;
|
|
|
123404
123555
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123405
123556
|
}
|
|
123406
123557
|
function invalidateResolutionsOfFailedLookupLocations() {
|
|
123558
|
+
var _a;
|
|
123559
|
+
var invalidated = false;
|
|
123560
|
+
if (affectingPathChecksForFile) {
|
|
123561
|
+
(_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
|
|
123562
|
+
if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
|
|
123563
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
|
|
123564
|
+
invalidated = true;
|
|
123565
|
+
}
|
|
123566
|
+
});
|
|
123567
|
+
affectingPathChecksForFile = undefined;
|
|
123568
|
+
}
|
|
123407
123569
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
|
123408
|
-
return
|
|
123570
|
+
return invalidated;
|
|
123571
|
+
}
|
|
123572
|
+
invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
|
|
123573
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123574
|
+
if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
|
|
123575
|
+
packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
|
|
123409
123576
|
}
|
|
123410
|
-
var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
|
|
123411
123577
|
failedLookupChecks = undefined;
|
|
123412
123578
|
startsWithPathChecks = undefined;
|
|
123413
123579
|
isInDirectoryChecks = undefined;
|
|
@@ -123420,17 +123586,15 @@ var ts;
|
|
|
123420
123586
|
return true;
|
|
123421
123587
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
|
|
123422
123588
|
return false;
|
|
123423
|
-
return resolution.failedLookupLocations.some(function (location) {
|
|
123424
|
-
|
|
123425
|
-
|
|
123426
|
-
|
|
123427
|
-
|
|
123428
|
-
|
|
123589
|
+
return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
|
|
123590
|
+
}
|
|
123591
|
+
function isInvalidatedFailedLookup(locationPath) {
|
|
123592
|
+
return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
|
|
123593
|
+
ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
|
|
123594
|
+
ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
|
|
123429
123595
|
}
|
|
123430
123596
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
123431
|
-
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
|
|
123432
|
-
return affectingPathChecks.has(resolutionHost.toPath(location));
|
|
123433
|
-
});
|
|
123597
|
+
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
|
|
123434
123598
|
}
|
|
123435
123599
|
function closeTypeRootsWatch() {
|
|
123436
123600
|
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
|
|
@@ -123496,7 +123660,7 @@ var ts;
|
|
|
123496
123660
|
function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
|
|
123497
123661
|
var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
|
|
123498
123662
|
var dirPath = resolutionHost.toPath(dir);
|
|
123499
|
-
return dirPath === rootPath ||
|
|
123663
|
+
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
123500
123664
|
}
|
|
123501
123665
|
}
|
|
123502
123666
|
ts.createResolutionCache = createResolutionCache;
|
|
@@ -123607,7 +123771,7 @@ var ts;
|
|
|
123607
123771
|
var info = getInfo(importingSourceFileName, host);
|
|
123608
123772
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123609
123773
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123610
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123774
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123611
123775
|
}
|
|
123612
123776
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123613
123777
|
if (options === void 0) { options = {}; }
|
|
@@ -123690,7 +123854,7 @@ var ts;
|
|
|
123690
123854
|
return nodeModulesSpecifiers;
|
|
123691
123855
|
}
|
|
123692
123856
|
if (!specifier && !modulePath.isRedirect) {
|
|
123693
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123857
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123694
123858
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123695
123859
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123696
123860
|
}
|
|
@@ -123718,7 +123882,7 @@ var ts;
|
|
|
123718
123882
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123719
123883
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123720
123884
|
}
|
|
123721
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123885
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123722
123886
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123723
123887
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123724
123888
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123732,9 +123896,8 @@ var ts;
|
|
|
123732
123896
|
if (!relativeToBaseUrl) {
|
|
123733
123897
|
return relativePath;
|
|
123734
123898
|
}
|
|
123735
|
-
var
|
|
123736
|
-
var
|
|
123737
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123899
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123900
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123738
123901
|
if (!nonRelative) {
|
|
123739
123902
|
return relativePath;
|
|
123740
123903
|
}
|
|
@@ -123969,28 +124132,102 @@ var ts;
|
|
|
123969
124132
|
return ambientModuleDeclare.name.text;
|
|
123970
124133
|
}
|
|
123971
124134
|
}
|
|
123972
|
-
function
|
|
124135
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
124136
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
124137
|
+
return [2 /* JsExtension */];
|
|
124138
|
+
}
|
|
124139
|
+
switch (preferredEnding) {
|
|
124140
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
124141
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
124142
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
124143
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
124144
|
+
}
|
|
124145
|
+
}
|
|
124146
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
123973
124147
|
for (var key in paths) {
|
|
123974
|
-
|
|
123975
|
-
var
|
|
123976
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
124148
|
+
var _loop_36 = function (patternText_1) {
|
|
124149
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
123977
124150
|
var indexOfStar = pattern.indexOf("*");
|
|
124151
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
124152
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
124153
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
124154
|
+
// and matches the '*'. For example:
|
|
124155
|
+
//
|
|
124156
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
124157
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
124158
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
124159
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
124160
|
+
//
|
|
124161
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
124162
|
+
//
|
|
124163
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
124164
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
124165
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
124166
|
+
// extension for a module specifier.)
|
|
124167
|
+
//
|
|
124168
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
124169
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
124170
|
+
//
|
|
124171
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
124172
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
124173
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
124174
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
124175
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
124176
|
+
// 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
|
|
124177
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
124178
|
+
//
|
|
124179
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
124180
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
124181
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
124182
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
124183
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
124184
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124185
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124186
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124187
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124188
|
+
ending: ending,
|
|
124189
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124190
|
+
}); });
|
|
124191
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124192
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124193
|
+
}
|
|
123978
124194
|
if (indexOfStar !== -1) {
|
|
123979
|
-
var prefix = pattern.
|
|
123980
|
-
var suffix = pattern.
|
|
123981
|
-
|
|
123982
|
-
|
|
123983
|
-
|
|
123984
|
-
|
|
123985
|
-
|
|
123986
|
-
|
|
124195
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124196
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124197
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124198
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124199
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124200
|
+
ts.startsWith(value, prefix) &&
|
|
124201
|
+
ts.endsWith(value, suffix) &&
|
|
124202
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124203
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124204
|
+
return { value: key.replace("*", matchedStar) };
|
|
124205
|
+
}
|
|
123987
124206
|
}
|
|
123988
124207
|
}
|
|
123989
|
-
else if (
|
|
123990
|
-
return
|
|
124208
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124209
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124210
|
+
return { value: key };
|
|
123991
124211
|
}
|
|
124212
|
+
};
|
|
124213
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124214
|
+
var patternText_1 = _a[_i];
|
|
124215
|
+
var state_12 = _loop_36(patternText_1);
|
|
124216
|
+
if (typeof state_12 === "object")
|
|
124217
|
+
return state_12.value;
|
|
123992
124218
|
}
|
|
123993
124219
|
}
|
|
124220
|
+
function validateEnding(_a) {
|
|
124221
|
+
var ending = _a.ending, value = _a.value;
|
|
124222
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124223
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124224
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124225
|
+
// 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
|
|
124226
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124227
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124228
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124229
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124230
|
+
}
|
|
123994
124231
|
}
|
|
123995
124232
|
var MatchingMode;
|
|
123996
124233
|
(function (MatchingMode) {
|
|
@@ -124086,10 +124323,10 @@ var ts;
|
|
|
124086
124323
|
return undefined;
|
|
124087
124324
|
}
|
|
124088
124325
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124326
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124089
124327
|
var moduleSpecifier = path;
|
|
124090
124328
|
var isPackageRootPath = false;
|
|
124091
124329
|
if (!packageNameOnly) {
|
|
124092
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124093
124330
|
var packageRootIndex = parts.packageRootIndex;
|
|
124094
124331
|
var moduleFileName = void 0;
|
|
124095
124332
|
while (true) {
|
|
@@ -124138,15 +124375,13 @@ var ts;
|
|
|
124138
124375
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
124139
124376
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
124140
124377
|
var moduleFileToTry = path;
|
|
124378
|
+
var maybeBlockedByTypesVersions = false;
|
|
124141
124379
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
124142
124380
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
124143
124381
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124382
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
124144
124383
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
124145
|
-
|
|
124146
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
124147
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
124148
|
-
// with, so for now we just stick with the mode of the file.
|
|
124149
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124384
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124150
124385
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
124151
124386
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
124152
124387
|
: undefined;
|
|
@@ -124165,16 +124400,26 @@ var ts;
|
|
|
124165
124400
|
: undefined;
|
|
124166
124401
|
if (versionPaths) {
|
|
124167
124402
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
124168
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
124169
|
-
if (fromPaths
|
|
124403
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124404
|
+
if (fromPaths === undefined) {
|
|
124405
|
+
maybeBlockedByTypesVersions = true;
|
|
124406
|
+
}
|
|
124407
|
+
else {
|
|
124170
124408
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
124171
124409
|
}
|
|
124172
124410
|
}
|
|
124173
124411
|
// If the file is the main module, it can be imported by the package name
|
|
124174
124412
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
124175
|
-
if (ts.isString(mainFileRelative)) {
|
|
124413
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124414
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124415
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124416
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124417
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124418
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124419
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
124176
124420
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
124177
124421
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124422
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
124178
124423
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
124179
124424
|
}
|
|
124180
124425
|
}
|
|
@@ -124469,23 +124714,46 @@ var ts;
|
|
|
124469
124714
|
var file = _c[_i];
|
|
124470
124715
|
write("" + toFileName(file, relativeFileName));
|
|
124471
124716
|
(_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
|
|
124472
|
-
(_b =
|
|
124717
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
|
|
124473
124718
|
}
|
|
124474
124719
|
}
|
|
124475
124720
|
ts.explainFiles = explainFiles;
|
|
124476
|
-
function
|
|
124721
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
124722
|
+
var _a;
|
|
124477
124723
|
var result;
|
|
124478
124724
|
if (file.path !== file.resolvedPath) {
|
|
124479
|
-
(result
|
|
124725
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124480
124726
|
/*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
|
|
124481
124727
|
}
|
|
124482
124728
|
if (file.redirectInfo) {
|
|
124483
|
-
(result
|
|
124729
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124484
124730
|
/*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
|
|
124485
124731
|
}
|
|
124732
|
+
if (ts.isExternalOrCommonJsModule(file)) {
|
|
124733
|
+
switch (file.impliedNodeFormat) {
|
|
124734
|
+
case ts.ModuleKind.ESNext:
|
|
124735
|
+
if (file.packageJsonScope) {
|
|
124736
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124737
|
+
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124738
|
+
}
|
|
124739
|
+
break;
|
|
124740
|
+
case ts.ModuleKind.CommonJS:
|
|
124741
|
+
if (file.packageJsonScope) {
|
|
124742
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124743
|
+
/*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
|
|
124744
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
|
124745
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124746
|
+
}
|
|
124747
|
+
else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
124748
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124749
|
+
/*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
|
|
124750
|
+
}
|
|
124751
|
+
break;
|
|
124752
|
+
}
|
|
124753
|
+
}
|
|
124486
124754
|
return result;
|
|
124487
124755
|
}
|
|
124488
|
-
ts.
|
|
124756
|
+
ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
|
|
124489
124757
|
function getMatchedFileSpec(program, fileName) {
|
|
124490
124758
|
var _a;
|
|
124491
124759
|
var configFile = program.getCompilerOptions().configFile;
|
|
@@ -124695,6 +124963,7 @@ var ts;
|
|
|
124695
124963
|
MissingFile: "Missing file",
|
|
124696
124964
|
WildcardDirectory: "Wild card directory",
|
|
124697
124965
|
FailedLookupLocations: "Failed Lookup Locations",
|
|
124966
|
+
AffectingFileLocation: "File location affecting resolution",
|
|
124698
124967
|
TypeRoots: "Type roots",
|
|
124699
124968
|
ConfigFileOfReferencedProject: "Config file of referened project",
|
|
124700
124969
|
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
|
@@ -125018,7 +125287,7 @@ var ts;
|
|
|
125018
125287
|
compilerHost.getCompilationSettings = function () { return compilerOptions; };
|
|
125019
125288
|
compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
|
|
125020
125289
|
compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
|
|
125021
|
-
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.
|
|
125290
|
+
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
|
|
125022
125291
|
compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
|
|
125023
125292
|
compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
|
|
125024
125293
|
compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
|
|
@@ -125052,6 +125321,9 @@ var ts;
|
|
|
125052
125321
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
125053
125322
|
}) :
|
|
125054
125323
|
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
125324
|
+
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
|
125325
|
+
ts.maybeBind(host, host.getModuleResolutionCache) :
|
|
125326
|
+
(function () { return resolutionCache.getModuleResolutionCache(); });
|
|
125055
125327
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
125056
125328
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
125057
125329
|
synchronizeProgram();
|
|
@@ -125154,8 +125426,9 @@ var ts;
|
|
|
125154
125426
|
resolutionCache.startCachingPerDirectoryResolution();
|
|
125155
125427
|
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
|
|
125156
125428
|
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
|
125429
|
+
var oldProgram = getCurrentProgram();
|
|
125157
125430
|
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
125158
|
-
resolutionCache.finishCachingPerDirectoryResolution();
|
|
125431
|
+
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
|
125159
125432
|
// Update watches
|
|
125160
125433
|
ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
|
|
125161
125434
|
if (needsUpdateInTypeRootWatch) {
|
|
@@ -125237,9 +125510,6 @@ var ts;
|
|
|
125237
125510
|
sourceFilesCache.set(path, false);
|
|
125238
125511
|
}
|
|
125239
125512
|
}
|
|
125240
|
-
if (sourceFile) {
|
|
125241
|
-
sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
|
125242
|
-
}
|
|
125243
125513
|
return sourceFile;
|
|
125244
125514
|
}
|
|
125245
125515
|
return hostSourceFile.sourceFile;
|
|
@@ -125755,6 +126025,7 @@ var ts;
|
|
|
125755
126025
|
compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
|
|
125756
126026
|
compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
|
|
125757
126027
|
compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
126028
|
+
compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
|
|
125758
126029
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
125759
126030
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
125760
126031
|
if (!compilerHost.resolveModuleNames) {
|
|
@@ -137973,60 +138244,64 @@ var ts;
|
|
|
137973
138244
|
}
|
|
137974
138245
|
return settingsOrHost;
|
|
137975
138246
|
}
|
|
137976
|
-
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
138247
|
+
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137977
138248
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137978
138249
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137979
|
-
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
138250
|
+
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137980
138251
|
}
|
|
137981
|
-
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137982
|
-
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
|
138252
|
+
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
138253
|
+
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
|
|
137983
138254
|
}
|
|
137984
|
-
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
138255
|
+
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137985
138256
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137986
138257
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137987
|
-
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
138258
|
+
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137988
138259
|
}
|
|
137989
|
-
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137990
|
-
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
|
138260
|
+
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
138261
|
+
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
|
|
137991
138262
|
}
|
|
137992
138263
|
function getDocumentRegistryEntry(bucketEntry, scriptKind) {
|
|
137993
138264
|
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"));
|
|
137994
138265
|
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);
|
|
137995
138266
|
return entry;
|
|
137996
138267
|
}
|
|
137997
|
-
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
138268
|
+
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) {
|
|
137998
138269
|
var _a, _b, _c, _d;
|
|
137999
138270
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
138000
138271
|
var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
|
|
138001
138272
|
var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
|
|
138002
138273
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
138003
|
-
var sourceFileOptions =
|
|
138004
|
-
|
|
138005
|
-
|
|
138006
|
-
|
|
138007
|
-
|
|
138274
|
+
var sourceFileOptions = typeof languageVersionOrOptions === "object" ?
|
|
138275
|
+
languageVersionOrOptions :
|
|
138276
|
+
{
|
|
138277
|
+
languageVersion: scriptTarget,
|
|
138278
|
+
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),
|
|
138279
|
+
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
|
|
138280
|
+
};
|
|
138281
|
+
sourceFileOptions.languageVersion = scriptTarget;
|
|
138008
138282
|
var oldBucketCount = buckets.size;
|
|
138009
|
-
var
|
|
138283
|
+
var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
|
|
138284
|
+
var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); });
|
|
138010
138285
|
if (ts.tracing) {
|
|
138011
138286
|
if (buckets.size > oldBucketCount) {
|
|
138012
138287
|
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
138013
138288
|
// perhaps they are for two projects that don't have any overlap.
|
|
138014
138289
|
// Bonus: these events can help us interpret the more interesting event below.
|
|
138015
|
-
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key:
|
|
138290
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
|
|
138016
138291
|
}
|
|
138017
138292
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
138018
138293
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
138019
138294
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
138020
138295
|
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
138021
|
-
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !==
|
|
138296
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; });
|
|
138022
138297
|
if (otherBucketKey) {
|
|
138023
|
-
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2:
|
|
138298
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode });
|
|
138024
138299
|
}
|
|
138025
138300
|
}
|
|
138026
138301
|
var bucketEntry = bucket.get(path);
|
|
138027
138302
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
138028
138303
|
if (!entry && externalCache) {
|
|
138029
|
-
var sourceFile = externalCache.getDocument(
|
|
138304
|
+
var sourceFile = externalCache.getDocument(keyWithMode, path);
|
|
138030
138305
|
if (sourceFile) {
|
|
138031
138306
|
ts.Debug.assert(acquiring);
|
|
138032
138307
|
entry = {
|
|
@@ -138040,7 +138315,7 @@ var ts;
|
|
|
138040
138315
|
// Have never seen this file with these settings. Create a new source file for it.
|
|
138041
138316
|
var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
|
|
138042
138317
|
if (externalCache) {
|
|
138043
|
-
externalCache.setDocument(
|
|
138318
|
+
externalCache.setDocument(keyWithMode, path, sourceFile);
|
|
138044
138319
|
}
|
|
138045
138320
|
entry = {
|
|
138046
138321
|
sourceFile: sourceFile,
|
|
@@ -138055,7 +138330,7 @@ var ts;
|
|
|
138055
138330
|
if (entry.sourceFile.version !== version) {
|
|
138056
138331
|
entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217
|
|
138057
138332
|
if (externalCache) {
|
|
138058
|
-
externalCache.setDocument(
|
|
138333
|
+
externalCache.setDocument(keyWithMode, path, entry.sourceFile);
|
|
138059
138334
|
}
|
|
138060
138335
|
}
|
|
138061
138336
|
// If we're acquiring, then this is the first time this LS is asking for this document.
|
|
@@ -138084,13 +138359,13 @@ var ts;
|
|
|
138084
138359
|
}
|
|
138085
138360
|
}
|
|
138086
138361
|
}
|
|
138087
|
-
function releaseDocument(fileName, compilationSettings, scriptKind) {
|
|
138362
|
+
function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) {
|
|
138088
138363
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
138089
138364
|
var key = getKeyForCompilationSettings(compilationSettings);
|
|
138090
|
-
return releaseDocumentWithKey(path, key, scriptKind);
|
|
138365
|
+
return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
|
|
138091
138366
|
}
|
|
138092
|
-
function releaseDocumentWithKey(path, key, scriptKind) {
|
|
138093
|
-
var bucket = ts.Debug.checkDefined(buckets.get(key));
|
|
138367
|
+
function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) {
|
|
138368
|
+
var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
|
|
138094
138369
|
var bucketEntry = bucket.get(path);
|
|
138095
138370
|
var entry = getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
138096
138371
|
entry.languageServiceRefCount--;
|
|
@@ -138147,6 +138422,9 @@ var ts;
|
|
|
138147
138422
|
function getKeyForCompilationSettings(settings) {
|
|
138148
138423
|
return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
|
|
138149
138424
|
}
|
|
138425
|
+
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
138426
|
+
return (mode ? key + "|" + mode : key);
|
|
138427
|
+
}
|
|
138150
138428
|
})(ts || (ts = {}));
|
|
138151
138429
|
/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
|
|
138152
138430
|
/* @internal */
|
|
@@ -162206,6 +162484,9 @@ var ts;
|
|
|
162206
162484
|
if (!containingDecl) {
|
|
162207
162485
|
return;
|
|
162208
162486
|
}
|
|
162487
|
+
if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
|
|
162488
|
+
return;
|
|
162489
|
+
}
|
|
162209
162490
|
var checker = program.getTypeChecker();
|
|
162210
162491
|
var signatureSymbol = containingDecl.symbol;
|
|
162211
162492
|
if (!signatureSymbol) {
|
|
@@ -167390,12 +167671,12 @@ var ts;
|
|
|
167390
167671
|
// not part of the new program.
|
|
167391
167672
|
function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
|
|
167392
167673
|
var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
|
|
167393
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
|
|
167674
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
167394
167675
|
}
|
|
167395
|
-
function getOrCreateSourceFile(fileName,
|
|
167396
|
-
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName),
|
|
167676
|
+
function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
167677
|
+
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
167397
167678
|
}
|
|
167398
|
-
function getOrCreateSourceFileByPath(fileName, path,
|
|
167679
|
+
function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) {
|
|
167399
167680
|
ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
|
|
167400
167681
|
// The program is asking for this file, check first if the host can locate it.
|
|
167401
167682
|
// If the host can not locate the file, then it does not exist. return undefined
|
|
@@ -167438,17 +167719,17 @@ var ts;
|
|
|
167438
167719
|
// file's script kind, i.e. in one project some file is treated as ".ts"
|
|
167439
167720
|
// and in another as ".js"
|
|
167440
167721
|
if (scriptKind === oldSourceFile.scriptKind) {
|
|
167441
|
-
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167722
|
+
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
167442
167723
|
}
|
|
167443
167724
|
else {
|
|
167444
167725
|
// Release old source file and fall through to aquire new file with new script kind
|
|
167445
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
|
|
167726
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
167446
167727
|
}
|
|
167447
167728
|
}
|
|
167448
167729
|
// We didn't already have the file. Fall through and acquire it from the registry.
|
|
167449
167730
|
}
|
|
167450
167731
|
// Could not find this file in the old program, create a new SourceFile for it.
|
|
167451
|
-
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167732
|
+
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
167452
167733
|
}
|
|
167453
167734
|
}
|
|
167454
167735
|
// TODO: GH#18217 frequently asserted as defined
|
|
@@ -167527,7 +167808,7 @@ var ts;
|
|
|
167527
167808
|
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
|
|
167528
167809
|
var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
|
167529
167810
|
ts.forEach(program.getSourceFiles(), function (f) {
|
|
167530
|
-
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind);
|
|
167811
|
+
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat);
|
|
167531
167812
|
});
|
|
167532
167813
|
program = undefined; // TODO: GH#18217
|
|
167533
167814
|
}
|
|
@@ -168444,6 +168725,7 @@ var ts;
|
|
|
168444
168725
|
getEmitOutput: getEmitOutput,
|
|
168445
168726
|
getNonBoundSourceFile: getNonBoundSourceFile,
|
|
168446
168727
|
getProgram: getProgram,
|
|
168728
|
+
getCurrentProgram: function () { return program; },
|
|
168447
168729
|
getAutoImportProvider: getAutoImportProvider,
|
|
168448
168730
|
updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
|
|
168449
168731
|
getApplicableRefactors: getApplicableRefactors,
|