typescript 4.8.0-dev.20220801 → 4.8.0-dev.20220804
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.es2015.promise.d.ts +9 -4
- package/lib/lib.es5.d.ts +2 -2
- package/lib/tsc.js +433 -226
- package/lib/tsserver.js +576 -294
- package/lib/tsserverlibrary.d.ts +16 -10
- package/lib/tsserverlibrary.js +576 -294
- package/lib/typescript.d.ts +16 -10
- package/lib/typescript.js +571 -289
- package/lib/typescriptServices.d.ts +16 -10
- package/lib/typescriptServices.js +571 -289
- package/lib/typingsInstaller.js +527 -256
- package/package.json +4 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220804";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8551,6 +8551,10 @@ var ts;
|
|
|
8551
8551
|
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."),
|
|
8552
8552
|
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`."),
|
|
8553
8553
|
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 '**/*'"),
|
|
8554
|
+
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\""),
|
|
8555
|
+
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\""),
|
|
8556
|
+
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\""),
|
|
8557
|
+
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"),
|
|
8554
8558
|
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."),
|
|
8555
8559
|
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."),
|
|
8556
8560
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -21854,7 +21858,7 @@ var ts;
|
|
|
21854
21858
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
21855
21859
|
* property or element access.
|
|
21856
21860
|
*/
|
|
21857
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
21861
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
21858
21862
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
21859
21863
|
// to parenthesize the expression before a dot. The known exception is:
|
|
21860
21864
|
//
|
|
@@ -21863,7 +21867,8 @@ var ts;
|
|
|
21863
21867
|
//
|
|
21864
21868
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
21865
21869
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
21866
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21870
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21871
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
21867
21872
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
21868
21873
|
return expression;
|
|
21869
21874
|
}
|
|
@@ -23270,7 +23275,7 @@ var ts;
|
|
|
23270
23275
|
// @api
|
|
23271
23276
|
function createDecorator(expression) {
|
|
23272
23277
|
var node = createBaseNode(165 /* Decorator */);
|
|
23273
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23278
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23274
23279
|
node.transformFlags |=
|
|
23275
23280
|
propagateChildFlags(node.expression) |
|
|
23276
23281
|
1 /* ContainsTypeScript */ |
|
|
@@ -24071,7 +24076,7 @@ var ts;
|
|
|
24071
24076
|
// @api
|
|
24072
24077
|
function createPropertyAccessExpression(expression, name) {
|
|
24073
24078
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24074
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24079
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24075
24080
|
node.name = asName(name);
|
|
24076
24081
|
node.transformFlags =
|
|
24077
24082
|
propagateChildFlags(node.expression) |
|
|
@@ -24101,7 +24106,7 @@ var ts;
|
|
|
24101
24106
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24102
24107
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24103
24108
|
node.flags |= 32 /* OptionalChain */;
|
|
24104
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24109
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24105
24110
|
node.questionDotToken = questionDotToken;
|
|
24106
24111
|
node.name = asName(name);
|
|
24107
24112
|
node.transformFlags |=
|
|
@@ -24127,7 +24132,7 @@ var ts;
|
|
|
24127
24132
|
// @api
|
|
24128
24133
|
function createElementAccessExpression(expression, index) {
|
|
24129
24134
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24130
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24135
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24131
24136
|
node.argumentExpression = asExpression(index);
|
|
24132
24137
|
node.transformFlags |=
|
|
24133
24138
|
propagateChildFlags(node.expression) |
|
|
@@ -24155,7 +24160,7 @@ var ts;
|
|
|
24155
24160
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24156
24161
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24157
24162
|
node.flags |= 32 /* OptionalChain */;
|
|
24158
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24163
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24159
24164
|
node.questionDotToken = questionDotToken;
|
|
24160
24165
|
node.argumentExpression = asExpression(index);
|
|
24161
24166
|
node.transformFlags |=
|
|
@@ -24179,7 +24184,7 @@ var ts;
|
|
|
24179
24184
|
// @api
|
|
24180
24185
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24181
24186
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24182
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24187
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24183
24188
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24184
24189
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24185
24190
|
node.transformFlags |=
|
|
@@ -24212,7 +24217,7 @@ var ts;
|
|
|
24212
24217
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24213
24218
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24214
24219
|
node.flags |= 32 /* OptionalChain */;
|
|
24215
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24220
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24216
24221
|
node.questionDotToken = questionDotToken;
|
|
24217
24222
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24218
24223
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24267,7 +24272,7 @@ var ts;
|
|
|
24267
24272
|
// @api
|
|
24268
24273
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24269
24274
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24270
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24275
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24271
24276
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24272
24277
|
node.template = template;
|
|
24273
24278
|
node.transformFlags |=
|
|
@@ -24705,7 +24710,7 @@ var ts;
|
|
|
24705
24710
|
// @api
|
|
24706
24711
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24707
24712
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24708
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24713
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24709
24714
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24710
24715
|
node.transformFlags |=
|
|
24711
24716
|
propagateChildFlags(node.expression) |
|
|
@@ -24741,7 +24746,7 @@ var ts;
|
|
|
24741
24746
|
// @api
|
|
24742
24747
|
function createNonNullExpression(expression) {
|
|
24743
24748
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24744
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24749
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24745
24750
|
node.transformFlags |=
|
|
24746
24751
|
propagateChildFlags(node.expression) |
|
|
24747
24752
|
1 /* ContainsTypeScript */;
|
|
@@ -24760,7 +24765,7 @@ var ts;
|
|
|
24760
24765
|
function createNonNullChain(expression) {
|
|
24761
24766
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24762
24767
|
node.flags |= 32 /* OptionalChain */;
|
|
24763
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24768
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24764
24769
|
node.transformFlags |=
|
|
24765
24770
|
propagateChildFlags(node.expression) |
|
|
24766
24771
|
1 /* ContainsTypeScript */;
|
|
@@ -26964,7 +26969,7 @@ var ts;
|
|
|
26964
26969
|
}
|
|
26965
26970
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
26966
26971
|
thisArg = createVoidZero();
|
|
26967
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
26972
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
26968
26973
|
}
|
|
26969
26974
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
26970
26975
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -26993,7 +26998,7 @@ var ts;
|
|
|
26993
26998
|
else {
|
|
26994
26999
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
26995
27000
|
thisArg = createVoidZero();
|
|
26996
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27001
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
26997
27002
|
}
|
|
26998
27003
|
return { target: target, thisArg: thisArg };
|
|
26999
27004
|
}
|
|
@@ -43228,7 +43233,7 @@ var ts;
|
|
|
43228
43233
|
ts.createCacheWithRedirects = createCacheWithRedirects;
|
|
43229
43234
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
43230
43235
|
var cache;
|
|
43231
|
-
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
|
|
43236
|
+
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
|
|
43232
43237
|
function getPackageJsonInfo(packageJsonPath) {
|
|
43233
43238
|
return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
|
|
43234
43239
|
}
|
|
@@ -43242,6 +43247,9 @@ var ts;
|
|
|
43242
43247
|
var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
|
|
43243
43248
|
return iter ? ts.arrayFrom(iter) : [];
|
|
43244
43249
|
}
|
|
43250
|
+
function getInternalMap() {
|
|
43251
|
+
return cache;
|
|
43252
|
+
}
|
|
43245
43253
|
}
|
|
43246
43254
|
function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
|
|
43247
43255
|
var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
@@ -43345,15 +43353,18 @@ var ts;
|
|
|
43345
43353
|
}
|
|
43346
43354
|
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
43347
43355
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
43348
|
-
var
|
|
43356
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43349
43357
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
43350
43358
|
var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
43351
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43359
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43352
43360
|
function clear() {
|
|
43353
|
-
|
|
43354
|
-
moduleNameToDirectoryMap.clear();
|
|
43361
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43355
43362
|
packageJsonInfoCache.clear();
|
|
43356
43363
|
}
|
|
43364
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43365
|
+
perDirectoryResolutionCache.clear();
|
|
43366
|
+
moduleNameToDirectoryMap.clear();
|
|
43367
|
+
}
|
|
43357
43368
|
function update(options) {
|
|
43358
43369
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
43359
43370
|
}
|
|
@@ -43429,13 +43440,16 @@ var ts;
|
|
|
43429
43440
|
}
|
|
43430
43441
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
43431
43442
|
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
|
|
43432
|
-
var
|
|
43443
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43433
43444
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
43434
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43445
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43435
43446
|
function clear() {
|
|
43436
|
-
|
|
43447
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43437
43448
|
packageJsonInfoCache.clear();
|
|
43438
43449
|
}
|
|
43450
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43451
|
+
perDirectoryResolutionCache.clear();
|
|
43452
|
+
}
|
|
43439
43453
|
}
|
|
43440
43454
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
43441
43455
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
@@ -51223,10 +51237,6 @@ var ts;
|
|
|
51223
51237
|
checkExpressionCached(expression);
|
|
51224
51238
|
return getNodeLinks(expression).resolvedSymbol;
|
|
51225
51239
|
}
|
|
51226
|
-
function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
|
|
51227
|
-
var expression = node.initializer;
|
|
51228
|
-
return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
|
|
51229
|
-
}
|
|
51230
51240
|
function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
|
|
51231
51241
|
if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
|
|
51232
51242
|
return undefined;
|
|
@@ -51258,7 +51268,7 @@ var ts;
|
|
|
51258
51268
|
case 297 /* ShorthandPropertyAssignment */:
|
|
51259
51269
|
return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
|
|
51260
51270
|
case 296 /* PropertyAssignment */:
|
|
51261
|
-
return
|
|
51271
|
+
return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
|
|
51262
51272
|
case 207 /* ElementAccessExpression */:
|
|
51263
51273
|
case 206 /* PropertyAccessExpression */:
|
|
51264
51274
|
return getTargetOfAccessExpression(node, dontRecursivelyResolve);
|
|
@@ -56783,7 +56793,7 @@ var ts;
|
|
|
56783
56793
|
(resolvedSymbol || symbol).exports.forEach(function (s, name) {
|
|
56784
56794
|
var _a;
|
|
56785
56795
|
var exportedMember = members_4.get(name);
|
|
56786
|
-
if (exportedMember && exportedMember !== s) {
|
|
56796
|
+
if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
|
|
56787
56797
|
if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
|
|
56788
56798
|
// If the member has an additional value-like declaration, union the types from the two declarations,
|
|
56789
56799
|
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
|
|
@@ -63275,6 +63285,7 @@ var ts;
|
|
|
63275
63285
|
}
|
|
63276
63286
|
}
|
|
63277
63287
|
function getTypeFromImportTypeNode(node) {
|
|
63288
|
+
var _a;
|
|
63278
63289
|
var links = getNodeLinks(node);
|
|
63279
63290
|
if (!links.resolvedType) {
|
|
63280
63291
|
if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
|
|
@@ -63294,6 +63305,7 @@ var ts;
|
|
|
63294
63305
|
links.resolvedSymbol = unknownSymbol;
|
|
63295
63306
|
return links.resolvedType = errorType;
|
|
63296
63307
|
}
|
|
63308
|
+
var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
|
|
63297
63309
|
var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
|
|
63298
63310
|
if (!ts.nodeIsMissing(node.qualifier)) {
|
|
63299
63311
|
var nameStack = getIdentifierChain(node.qualifier);
|
|
@@ -63305,9 +63317,11 @@ var ts;
|
|
|
63305
63317
|
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
|
|
63306
63318
|
// the `exports` lookup process that only looks up namespace members which is used for most type references
|
|
63307
63319
|
var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
|
|
63308
|
-
var
|
|
63320
|
+
var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
|
|
63309
63321
|
? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
|
|
63310
|
-
:
|
|
63322
|
+
: undefined;
|
|
63323
|
+
var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
|
|
63324
|
+
var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
|
|
63311
63325
|
if (!next) {
|
|
63312
63326
|
error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
|
|
63313
63327
|
return links.resolvedType = errorType;
|
|
@@ -66165,6 +66179,26 @@ var ts;
|
|
|
66165
66179
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66166
66180
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66167
66181
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66182
|
+
if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
|
|
66183
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66184
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
66185
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66186
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66187
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66188
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66189
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66190
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66191
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
66192
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66193
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66194
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66195
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66196
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66197
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66198
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66199
|
+
result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66200
|
+
}
|
|
66201
|
+
}
|
|
66168
66202
|
if (result) {
|
|
66169
66203
|
resetErrorInfo(saveErrorInfo);
|
|
66170
66204
|
}
|
|
@@ -66222,28 +66256,6 @@ var ts;
|
|
|
66222
66256
|
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
66223
66257
|
return result;
|
|
66224
66258
|
}
|
|
66225
|
-
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
66226
|
-
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66227
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
66228
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66229
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66230
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66231
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66232
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66233
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66234
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
66235
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66236
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66237
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66238
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66239
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66240
|
-
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66241
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66242
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66243
|
-
return result;
|
|
66244
|
-
}
|
|
66245
|
-
}
|
|
66246
|
-
}
|
|
66247
66259
|
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
66248
66260
|
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
66249
66261
|
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
@@ -82097,9 +82109,11 @@ var ts;
|
|
|
82097
82109
|
// We only need `Awaited<T>` if `T` contains possibly non-primitive types.
|
|
82098
82110
|
if (isGenericObjectType(type)) {
|
|
82099
82111
|
var baseConstraint = getBaseConstraintOfType(type);
|
|
82100
|
-
// We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82112
|
+
// 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`,
|
|
82101
82113
|
// or is promise-like.
|
|
82102
|
-
if (
|
|
82114
|
+
if (baseConstraint ?
|
|
82115
|
+
baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
|
|
82116
|
+
maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
|
|
82103
82117
|
return true;
|
|
82104
82118
|
}
|
|
82105
82119
|
}
|
|
@@ -83976,17 +83990,28 @@ var ts;
|
|
|
83976
83990
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
83977
83991
|
*/
|
|
83978
83992
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
83993
|
+
var _a, _b;
|
|
83979
83994
|
if (isTypeAny(type)) {
|
|
83980
83995
|
return anyIterationTypes;
|
|
83981
83996
|
}
|
|
83982
83997
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
83983
|
-
var
|
|
83998
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
83999
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
83984
84000
|
if (iterationTypes_1 === noIterationTypes) {
|
|
83985
84001
|
if (errorNode) {
|
|
83986
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84002
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84003
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84004
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84005
|
+
}
|
|
83987
84006
|
}
|
|
83988
84007
|
return undefined;
|
|
83989
84008
|
}
|
|
84009
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84010
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84011
|
+
var diag = _c[_i];
|
|
84012
|
+
diagnostics.add(diag);
|
|
84013
|
+
}
|
|
84014
|
+
}
|
|
83990
84015
|
return iterationTypes_1;
|
|
83991
84016
|
}
|
|
83992
84017
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -83994,19 +84019,27 @@ var ts;
|
|
|
83994
84019
|
if (cachedTypes)
|
|
83995
84020
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
83996
84021
|
var allIterationTypes;
|
|
83997
|
-
for (var
|
|
83998
|
-
var constituent =
|
|
83999
|
-
var
|
|
84022
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84023
|
+
var constituent = _e[_d];
|
|
84024
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84025
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84000
84026
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84001
84027
|
if (errorNode) {
|
|
84002
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84028
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84029
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84030
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84031
|
+
}
|
|
84003
84032
|
}
|
|
84004
84033
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84005
84034
|
return undefined;
|
|
84006
84035
|
}
|
|
84007
|
-
else {
|
|
84008
|
-
|
|
84036
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84037
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84038
|
+
var diag = _g[_f];
|
|
84039
|
+
diagnostics.add(diag);
|
|
84040
|
+
}
|
|
84009
84041
|
}
|
|
84042
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84010
84043
|
}
|
|
84011
84044
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84012
84045
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84034,47 +84067,62 @@ var ts;
|
|
|
84034
84067
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84035
84068
|
* `getIterationTypesOfIterable` instead.
|
|
84036
84069
|
*/
|
|
84037
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84070
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84038
84071
|
if (isTypeAny(type)) {
|
|
84039
84072
|
return anyIterationTypes;
|
|
84040
84073
|
}
|
|
84074
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84075
|
+
// In addition, we should not cache any new results for this call.
|
|
84076
|
+
var noCache = false;
|
|
84041
84077
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84042
84078
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84043
84079
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84044
84080
|
if (iterationTypes) {
|
|
84045
|
-
|
|
84046
|
-
|
|
84047
|
-
|
|
84081
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84082
|
+
// ignore the cached value
|
|
84083
|
+
noCache = true;
|
|
84084
|
+
}
|
|
84085
|
+
else {
|
|
84086
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84087
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84088
|
+
iterationTypes;
|
|
84089
|
+
}
|
|
84048
84090
|
}
|
|
84049
84091
|
}
|
|
84050
84092
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84051
84093
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84052
84094
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84053
84095
|
if (iterationTypes) {
|
|
84054
|
-
if (
|
|
84055
|
-
//
|
|
84056
|
-
|
|
84057
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84058
|
-
}
|
|
84096
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84097
|
+
// ignore the cached value
|
|
84098
|
+
noCache = true;
|
|
84059
84099
|
}
|
|
84060
84100
|
else {
|
|
84061
|
-
|
|
84101
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84102
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84103
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84104
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84105
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84106
|
+
}
|
|
84107
|
+
}
|
|
84108
|
+
else {
|
|
84109
|
+
return iterationTypes;
|
|
84110
|
+
}
|
|
84062
84111
|
}
|
|
84063
84112
|
}
|
|
84064
84113
|
}
|
|
84065
84114
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84066
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84115
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84067
84116
|
if (iterationTypes !== noIterationTypes) {
|
|
84068
84117
|
return iterationTypes;
|
|
84069
84118
|
}
|
|
84070
84119
|
}
|
|
84071
84120
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84072
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84121
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84073
84122
|
if (iterationTypes !== noIterationTypes) {
|
|
84074
84123
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84075
|
-
|
|
84076
|
-
|
|
84077
|
-
: noIterationTypes);
|
|
84124
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84125
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84078
84126
|
}
|
|
84079
84127
|
else {
|
|
84080
84128
|
return iterationTypes;
|
|
@@ -84095,7 +84143,7 @@ var ts;
|
|
|
84095
84143
|
}
|
|
84096
84144
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84097
84145
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84098
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84146
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84099
84147
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84100
84148
|
}
|
|
84101
84149
|
/**
|
|
@@ -84149,26 +84197,26 @@ var ts;
|
|
|
84149
84197
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84150
84198
|
* `getIterationTypesOfIterable` instead.
|
|
84151
84199
|
*/
|
|
84152
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84200
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84153
84201
|
var _a;
|
|
84154
84202
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84155
84203
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84156
84204
|
if (isTypeAny(methodType)) {
|
|
84157
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84205
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84158
84206
|
}
|
|
84159
84207
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84160
84208
|
if (!ts.some(signatures)) {
|
|
84161
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84209
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84162
84210
|
}
|
|
84163
84211
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84164
|
-
var iterationTypes = (_a =
|
|
84165
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84212
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84213
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84166
84214
|
}
|
|
84167
84215
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84168
84216
|
var message = allowAsyncIterables
|
|
84169
84217
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84170
84218
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84171
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84219
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84172
84220
|
}
|
|
84173
84221
|
/**
|
|
84174
84222
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -84176,13 +84224,29 @@ var ts;
|
|
|
84176
84224
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84177
84225
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84178
84226
|
*/
|
|
84179
|
-
function getIterationTypesOfIterator(type, resolver, errorNode) {
|
|
84227
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84228
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84229
|
+
}
|
|
84230
|
+
/**
|
|
84231
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84232
|
+
*
|
|
84233
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84234
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84235
|
+
*
|
|
84236
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84237
|
+
* `getIterationTypesOfIterator` instead.
|
|
84238
|
+
*/
|
|
84239
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84180
84240
|
if (isTypeAny(type)) {
|
|
84181
84241
|
return anyIterationTypes;
|
|
84182
84242
|
}
|
|
84183
84243
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84184
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84185
|
-
|
|
84244
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84245
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84246
|
+
iterationTypes = undefined;
|
|
84247
|
+
noCache = true;
|
|
84248
|
+
}
|
|
84249
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84186
84250
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84187
84251
|
}
|
|
84188
84252
|
/**
|
|
@@ -84220,7 +84284,7 @@ var ts;
|
|
|
84220
84284
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84221
84285
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84222
84286
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84223
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84287
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84224
84288
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84225
84289
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84226
84290
|
}
|
|
@@ -84290,8 +84354,8 @@ var ts;
|
|
|
84290
84354
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84291
84355
|
* record is returned. Otherwise, we return `undefined`.
|
|
84292
84356
|
*/
|
|
84293
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84294
|
-
var _a, _b, _c, _d;
|
|
84357
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84358
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84295
84359
|
var method = getPropertyOfType(type, methodName);
|
|
84296
84360
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84297
84361
|
if (!method && methodName !== "next") {
|
|
@@ -84311,9 +84375,15 @@ var ts;
|
|
|
84311
84375
|
var diagnostic = methodName === "next"
|
|
84312
84376
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84313
84377
|
: resolver.mustBeAMethodDiagnostic;
|
|
84314
|
-
|
|
84378
|
+
if (errorOutputContainer) {
|
|
84379
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84380
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84381
|
+
}
|
|
84382
|
+
else {
|
|
84383
|
+
error(errorNode, diagnostic, methodName);
|
|
84384
|
+
}
|
|
84315
84385
|
}
|
|
84316
|
-
return methodName === "next" ?
|
|
84386
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84317
84387
|
}
|
|
84318
84388
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84319
84389
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84325,8 +84395,8 @@ var ts;
|
|
|
84325
84395
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84326
84396
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84327
84397
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84328
|
-
var isGeneratorMethod = ((
|
|
84329
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84398
|
+
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;
|
|
84399
|
+
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;
|
|
84330
84400
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84331
84401
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84332
84402
|
var mapper = methodType.mapper;
|
|
@@ -84366,7 +84436,13 @@ var ts;
|
|
|
84366
84436
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84367
84437
|
if (iterationTypes === noIterationTypes) {
|
|
84368
84438
|
if (errorNode) {
|
|
84369
|
-
|
|
84439
|
+
if (errorOutputContainer) {
|
|
84440
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84441
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84442
|
+
}
|
|
84443
|
+
else {
|
|
84444
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84445
|
+
}
|
|
84370
84446
|
}
|
|
84371
84447
|
yieldType = anyType;
|
|
84372
84448
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84387,13 +84463,13 @@ var ts;
|
|
|
84387
84463
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84388
84464
|
* `getIterationTypesOfIterator` instead.
|
|
84389
84465
|
*/
|
|
84390
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84466
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84391
84467
|
var iterationTypes = combineIterationTypes([
|
|
84392
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84393
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84394
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84468
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84469
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84470
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84395
84471
|
]);
|
|
84396
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84472
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84397
84473
|
}
|
|
84398
84474
|
/**
|
|
84399
84475
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84414,7 +84490,7 @@ var ts;
|
|
|
84414
84490
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84415
84491
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84416
84492
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84417
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84493
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84418
84494
|
}
|
|
84419
84495
|
function checkBreakOrContinueStatement(node) {
|
|
84420
84496
|
// Grammar checking
|
|
@@ -94871,10 +94947,11 @@ var ts;
|
|
|
94871
94947
|
}
|
|
94872
94948
|
function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
|
|
94873
94949
|
if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
|
|
94874
|
-
|
|
94950
|
+
var operand = ts.skipParentheses(node.operand);
|
|
94951
|
+
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
|
|
94875
94952
|
var info = void 0;
|
|
94876
|
-
if (info = accessPrivateIdentifier(
|
|
94877
|
-
var receiver = ts.visitNode(
|
|
94953
|
+
if (info = accessPrivateIdentifier(operand.name)) {
|
|
94954
|
+
var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
|
|
94878
94955
|
var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
|
|
94879
94956
|
var expression = createPrivateIdentifierAccess(info, readExpression);
|
|
94880
94957
|
var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
@@ -94890,7 +94967,7 @@ var ts;
|
|
|
94890
94967
|
}
|
|
94891
94968
|
}
|
|
94892
94969
|
else if (shouldTransformSuperInStaticInitializers &&
|
|
94893
|
-
ts.isSuperProperty(
|
|
94970
|
+
ts.isSuperProperty(operand) &&
|
|
94894
94971
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
94895
94972
|
currentClassLexicalEnvironment) {
|
|
94896
94973
|
// converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
|
|
@@ -94903,31 +94980,31 @@ var ts;
|
|
|
94903
94980
|
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
|
|
94904
94981
|
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
|
|
94905
94982
|
if (facts & 1 /* ClassWasDecorated */) {
|
|
94906
|
-
var
|
|
94983
|
+
var expression = visitInvalidSuperProperty(operand);
|
|
94907
94984
|
return ts.isPrefixUnaryExpression(node) ?
|
|
94908
|
-
factory.updatePrefixUnaryExpression(node,
|
|
94909
|
-
factory.updatePostfixUnaryExpression(node,
|
|
94985
|
+
factory.updatePrefixUnaryExpression(node, expression) :
|
|
94986
|
+
factory.updatePostfixUnaryExpression(node, expression);
|
|
94910
94987
|
}
|
|
94911
94988
|
if (classConstructor && superClassReference) {
|
|
94912
94989
|
var setterName = void 0;
|
|
94913
94990
|
var getterName = void 0;
|
|
94914
|
-
if (ts.isPropertyAccessExpression(
|
|
94915
|
-
if (ts.isIdentifier(
|
|
94916
|
-
getterName = setterName = factory.createStringLiteralFromNode(
|
|
94991
|
+
if (ts.isPropertyAccessExpression(operand)) {
|
|
94992
|
+
if (ts.isIdentifier(operand.name)) {
|
|
94993
|
+
getterName = setterName = factory.createStringLiteralFromNode(operand.name);
|
|
94917
94994
|
}
|
|
94918
94995
|
}
|
|
94919
94996
|
else {
|
|
94920
|
-
if (ts.isSimpleInlineableExpression(
|
|
94921
|
-
getterName = setterName =
|
|
94997
|
+
if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
|
|
94998
|
+
getterName = setterName = operand.argumentExpression;
|
|
94922
94999
|
}
|
|
94923
95000
|
else {
|
|
94924
95001
|
getterName = factory.createTempVariable(hoistVariableDeclaration);
|
|
94925
|
-
setterName = factory.createAssignment(getterName, ts.visitNode(
|
|
95002
|
+
setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
|
|
94926
95003
|
}
|
|
94927
95004
|
}
|
|
94928
95005
|
if (setterName && getterName) {
|
|
94929
95006
|
var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
|
|
94930
|
-
ts.setTextRange(expression,
|
|
95007
|
+
ts.setTextRange(expression, operand);
|
|
94931
95008
|
var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
94932
95009
|
expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
|
|
94933
95010
|
expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
|
|
@@ -117682,6 +117759,12 @@ var ts;
|
|
|
117682
117759
|
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
117683
117760
|
*/
|
|
117684
117761
|
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
117762
|
+
var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
|
117763
|
+
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
117764
|
+
}
|
|
117765
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
117766
|
+
/*@internal*/
|
|
117767
|
+
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
117685
117768
|
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
117686
117769
|
case ts.ModuleResolutionKind.Node16:
|
|
117687
117770
|
case ts.ModuleResolutionKind.NodeNext:
|
|
@@ -117693,11 +117776,16 @@ var ts;
|
|
|
117693
117776
|
return undefined;
|
|
117694
117777
|
}
|
|
117695
117778
|
function lookupFromPackageJson() {
|
|
117696
|
-
var
|
|
117697
|
-
|
|
117779
|
+
var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
117780
|
+
var packageJsonLocations = [];
|
|
117781
|
+
state.failedLookupLocations = packageJsonLocations;
|
|
117782
|
+
state.affectingLocations = packageJsonLocations;
|
|
117783
|
+
var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
|
|
117784
|
+
var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
117785
|
+
return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
|
|
117698
117786
|
}
|
|
117699
117787
|
}
|
|
117700
|
-
ts.
|
|
117788
|
+
ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
|
|
117701
117789
|
/** @internal */
|
|
117702
117790
|
ts.plainJSErrors = new ts.Set([
|
|
117703
117791
|
// binder errors
|
|
@@ -118022,7 +118110,7 @@ var ts;
|
|
|
118022
118110
|
for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
|
|
118023
118111
|
var oldSourceFile = oldSourceFiles_1[_i];
|
|
118024
118112
|
var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
|
118025
|
-
if (shouldCreateNewSourceFile || !newFile ||
|
|
118113
|
+
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
118026
118114
|
// old file wasn't redirect but new file is
|
|
118027
118115
|
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
|
118028
118116
|
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
|
@@ -118415,7 +118503,7 @@ var ts;
|
|
|
118415
118503
|
});
|
|
118416
118504
|
}
|
|
118417
118505
|
function tryReuseStructureFromOldProgram() {
|
|
118418
|
-
var _a;
|
|
118506
|
+
var _a, _b;
|
|
118419
118507
|
if (!oldProgram) {
|
|
118420
118508
|
return 0 /* Not */;
|
|
118421
118509
|
}
|
|
@@ -118456,12 +118544,15 @@ var ts;
|
|
|
118456
118544
|
var seenPackageNames = new ts.Map();
|
|
118457
118545
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
118458
118546
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
118547
|
+
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
118459
118548
|
var newSourceFile = host.getSourceFileByPath
|
|
118460
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath,
|
|
118461
|
-
: host.getSourceFile(oldSourceFile.fileName,
|
|
118549
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
|
118550
|
+
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
|
118462
118551
|
if (!newSourceFile) {
|
|
118463
118552
|
return 0 /* Not */;
|
|
118464
118553
|
}
|
|
118554
|
+
newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
118555
|
+
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
118465
118556
|
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
|
118466
118557
|
var fileChanged = void 0;
|
|
118467
118558
|
if (oldSourceFile.redirectInfo) {
|
|
@@ -118501,38 +118592,43 @@ var ts;
|
|
|
118501
118592
|
seenPackageNames.set(packageName, newKind);
|
|
118502
118593
|
}
|
|
118503
118594
|
if (fileChanged) {
|
|
118595
|
+
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
|
118596
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118597
|
+
}
|
|
118504
118598
|
// The `newSourceFile` object was created for the new program.
|
|
118505
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118599
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118506
118600
|
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
|
118507
118601
|
structureIsReused = 1 /* SafeModules */;
|
|
118508
118602
|
}
|
|
118509
|
-
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118603
|
+
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118510
118604
|
// value of no-default-lib has changed
|
|
118511
118605
|
// this will affect if default library is injected into the list of files
|
|
118512
118606
|
structureIsReused = 1 /* SafeModules */;
|
|
118513
118607
|
}
|
|
118514
118608
|
// check tripleslash references
|
|
118515
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118609
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118516
118610
|
// tripleslash references has changed
|
|
118517
118611
|
structureIsReused = 1 /* SafeModules */;
|
|
118518
118612
|
}
|
|
118519
|
-
|
|
118520
|
-
|
|
118521
|
-
|
|
118522
|
-
|
|
118523
|
-
|
|
118524
|
-
|
|
118525
|
-
|
|
118526
|
-
|
|
118527
|
-
|
|
118528
|
-
|
|
118529
|
-
|
|
118530
|
-
|
|
118531
|
-
|
|
118532
|
-
|
|
118533
|
-
|
|
118534
|
-
|
|
118535
|
-
|
|
118613
|
+
else {
|
|
118614
|
+
// check imports and module augmentations
|
|
118615
|
+
collectExternalModuleReferences(newSourceFile);
|
|
118616
|
+
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
|
118617
|
+
// imports has changed
|
|
118618
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118619
|
+
}
|
|
118620
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
|
118621
|
+
// moduleAugmentations has changed
|
|
118622
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118623
|
+
}
|
|
118624
|
+
else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
118625
|
+
// dynamicImport has changed
|
|
118626
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118627
|
+
}
|
|
118628
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118629
|
+
// 'types' references has changed
|
|
118630
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118631
|
+
}
|
|
118536
118632
|
}
|
|
118537
118633
|
// tentatively approve the file
|
|
118538
118634
|
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
|
@@ -118550,18 +118646,18 @@ var ts;
|
|
|
118550
118646
|
return structureIsReused;
|
|
118551
118647
|
}
|
|
118552
118648
|
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
|
|
118553
|
-
for (var
|
|
118554
|
-
var oldFile = oldSourceFiles_3[
|
|
118649
|
+
for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
|
|
118650
|
+
var oldFile = oldSourceFiles_3[_c];
|
|
118555
118651
|
if (!ts.contains(modifiedFiles, oldFile)) {
|
|
118556
|
-
for (var
|
|
118557
|
-
var moduleName = _d
|
|
118652
|
+
for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
|
|
118653
|
+
var moduleName = _e[_d];
|
|
118558
118654
|
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
118559
118655
|
}
|
|
118560
118656
|
}
|
|
118561
118657
|
}
|
|
118562
118658
|
// try to verify results of module resolution
|
|
118563
|
-
for (var
|
|
118564
|
-
var
|
|
118659
|
+
for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
|
|
118660
|
+
var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
|
|
118565
118661
|
var moduleNames = getModuleNames(newSourceFile);
|
|
118566
118662
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
118567
118663
|
// ensure that module resolution results are still correct
|
|
@@ -118588,14 +118684,14 @@ var ts;
|
|
|
118588
118684
|
if (structureIsReused !== 2 /* Completely */) {
|
|
118589
118685
|
return structureIsReused;
|
|
118590
118686
|
}
|
|
118591
|
-
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((
|
|
118687
|
+
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
|
|
118592
118688
|
return 1 /* SafeModules */;
|
|
118593
118689
|
}
|
|
118594
118690
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
118595
118691
|
// update fileName -> file mapping
|
|
118596
118692
|
ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
118597
|
-
for (var
|
|
118598
|
-
var newSourceFile = newSourceFiles_1[
|
|
118693
|
+
for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
|
|
118694
|
+
var newSourceFile = newSourceFiles_1[_h];
|
|
118599
118695
|
filesByName.set(newSourceFile.path, newSourceFile);
|
|
118600
118696
|
}
|
|
118601
118697
|
var oldFilesByNameMap = oldProgram.getFilesByNameMap();
|
|
@@ -119378,13 +119474,16 @@ var ts;
|
|
|
119378
119474
|
addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
|
|
119379
119475
|
}
|
|
119380
119476
|
}
|
|
119381
|
-
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
|
|
119477
|
+
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
|
|
119478
|
+
var _a;
|
|
119382
119479
|
var redirect = Object.create(redirectTarget);
|
|
119383
119480
|
redirect.fileName = fileName;
|
|
119384
119481
|
redirect.path = path;
|
|
119385
119482
|
redirect.resolvedPath = resolvedPath;
|
|
119386
119483
|
redirect.originalFileName = originalFileName;
|
|
119387
119484
|
redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
|
|
119485
|
+
redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119486
|
+
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119388
119487
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
119389
119488
|
Object.defineProperties(redirect, {
|
|
119390
119489
|
id: {
|
|
@@ -119413,14 +119512,14 @@ var ts;
|
|
|
119413
119512
|
// 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
|
|
119414
119513
|
// 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
|
|
119415
119514
|
// 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.
|
|
119416
|
-
var
|
|
119417
|
-
|
|
119418
|
-
|
|
119419
|
-
|
|
119420
|
-
setExternalModuleIndicator:
|
|
119421
|
-
};
|
|
119515
|
+
var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
119516
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
119517
|
+
var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
|
|
119518
|
+
return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
|
|
119519
|
+
{ languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
|
|
119422
119520
|
}
|
|
119423
119521
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
119522
|
+
var _a, _b;
|
|
119424
119523
|
var path = toPath(fileName);
|
|
119425
119524
|
if (useSourceOfProjectReferenceRedirect) {
|
|
119426
119525
|
var source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -119507,14 +119606,15 @@ var ts;
|
|
|
119507
119606
|
}
|
|
119508
119607
|
}
|
|
119509
119608
|
// We haven't looked for this file, do so now and cache result
|
|
119510
|
-
var
|
|
119609
|
+
var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
119610
|
+
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));
|
|
119511
119611
|
if (packageId) {
|
|
119512
119612
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
119513
119613
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
119514
119614
|
if (fileFromPackageId) {
|
|
119515
119615
|
// Some other SourceFile already exists with this package name and version.
|
|
119516
119616
|
// Instead of creating a duplicate, just redirect to the existing one.
|
|
119517
|
-
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
|
|
119617
|
+
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
|
119518
119618
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
119519
119619
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
119520
119620
|
addFileIncludeReason(dupFile, reason);
|
|
@@ -119535,6 +119635,8 @@ var ts;
|
|
|
119535
119635
|
file.path = path;
|
|
119536
119636
|
file.resolvedPath = toPath(fileName);
|
|
119537
119637
|
file.originalFileName = originalFileName;
|
|
119638
|
+
file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119639
|
+
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119538
119640
|
addFileIncludeReason(file, reason);
|
|
119539
119641
|
if (host.useCaseSensitiveFileNames()) {
|
|
119540
119642
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -120165,7 +120267,7 @@ var ts;
|
|
|
120165
120267
|
fileIncludeReasons = undefined;
|
|
120166
120268
|
var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
|
|
120167
120269
|
var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
120168
|
-
var redirectInfo = file && ts.
|
|
120270
|
+
var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
|
|
120169
120271
|
var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
|
|
120170
120272
|
return location && isReferenceFileLocation(location) ?
|
|
120171
120273
|
ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
|
|
@@ -122470,7 +122572,7 @@ var ts;
|
|
|
122470
122572
|
* "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
|
|
122471
122573
|
* @param dirPath
|
|
122472
122574
|
*/
|
|
122473
|
-
function
|
|
122575
|
+
function canWatchDirectoryOrFile(dirPath) {
|
|
122474
122576
|
var rootLength = ts.getRootLength(dirPath);
|
|
122475
122577
|
if (dirPath.length === rootLength) {
|
|
122476
122578
|
// Ignore "/", "c:/"
|
|
@@ -122507,7 +122609,7 @@ var ts;
|
|
|
122507
122609
|
}
|
|
122508
122610
|
return true;
|
|
122509
122611
|
}
|
|
122510
|
-
ts.
|
|
122612
|
+
ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
|
|
122511
122613
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
122512
122614
|
var filesWithChangedSetOfUnresolvedImports;
|
|
122513
122615
|
var filesWithInvalidatedResolutions;
|
|
@@ -122516,7 +122618,9 @@ var ts;
|
|
|
122516
122618
|
var resolutionsWithFailedLookups = [];
|
|
122517
122619
|
var resolutionsWithOnlyAffectingLocations = [];
|
|
122518
122620
|
var resolvedFileToResolution = ts.createMultiMap();
|
|
122621
|
+
var impliedFormatPackageJsons = new ts.Map();
|
|
122519
122622
|
var hasChangedAutomaticTypeDirectiveNames = false;
|
|
122623
|
+
var affectingPathChecksForFile;
|
|
122520
122624
|
var affectingPathChecks;
|
|
122521
122625
|
var failedLookupChecks;
|
|
122522
122626
|
var startsWithPathChecks;
|
|
@@ -122556,7 +122660,7 @@ var ts;
|
|
|
122556
122660
|
finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
|
|
122557
122661
|
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122558
122662
|
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122559
|
-
startCachingPerDirectoryResolution:
|
|
122663
|
+
startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
|
|
122560
122664
|
finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
|
|
122561
122665
|
resolveModuleNames: resolveModuleNames,
|
|
122562
122666
|
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
@@ -122600,9 +122704,10 @@ var ts;
|
|
|
122600
122704
|
startsWithPathChecks = undefined;
|
|
122601
122705
|
isInDirectoryChecks = undefined;
|
|
122602
122706
|
affectingPathChecks = undefined;
|
|
122603
|
-
|
|
122604
|
-
|
|
122605
|
-
|
|
122707
|
+
affectingPathChecksForFile = undefined;
|
|
122708
|
+
moduleResolutionCache.clear();
|
|
122709
|
+
typeReferenceDirectiveResolutionCache.clear();
|
|
122710
|
+
impliedFormatPackageJsons.clear();
|
|
122606
122711
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122607
122712
|
}
|
|
122608
122713
|
function startRecordingFilesWithChangedResolutions() {
|
|
@@ -122634,15 +122739,44 @@ var ts;
|
|
|
122634
122739
|
return function (path) { return (!!collected && collected.has(path)) ||
|
|
122635
122740
|
isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
|
|
122636
122741
|
}
|
|
122637
|
-
function
|
|
122638
|
-
moduleResolutionCache.
|
|
122639
|
-
typeReferenceDirectiveResolutionCache.
|
|
122742
|
+
function startCachingPerDirectoryResolution() {
|
|
122743
|
+
moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122744
|
+
typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122745
|
+
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122746
|
+
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122640
122747
|
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122641
122748
|
nonRelativeExternalModuleResolutions.clear();
|
|
122642
122749
|
}
|
|
122643
|
-
function finishCachingPerDirectoryResolution() {
|
|
122750
|
+
function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
|
|
122644
122751
|
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
|
122645
|
-
|
|
122752
|
+
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122753
|
+
nonRelativeExternalModuleResolutions.clear();
|
|
122754
|
+
// Update file watches
|
|
122755
|
+
if (newProgram !== oldProgram) {
|
|
122756
|
+
newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
|
|
122757
|
+
var _a, _b, _c;
|
|
122758
|
+
var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
122759
|
+
var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
|
|
122760
|
+
for (var i = existing.length; i < expected; i++) {
|
|
122761
|
+
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
|
|
122762
|
+
}
|
|
122763
|
+
if (existing.length > expected) {
|
|
122764
|
+
for (var i = expected; i < existing.length; i++) {
|
|
122765
|
+
fileWatchesOfAffectingLocations.get(existing[i]).files--;
|
|
122766
|
+
}
|
|
122767
|
+
}
|
|
122768
|
+
if (expected)
|
|
122769
|
+
impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
|
|
122770
|
+
else
|
|
122771
|
+
impliedFormatPackageJsons.delete(newFile.path);
|
|
122772
|
+
});
|
|
122773
|
+
impliedFormatPackageJsons.forEach(function (existing, path) {
|
|
122774
|
+
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
122775
|
+
existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
|
|
122776
|
+
impliedFormatPackageJsons.delete(path);
|
|
122777
|
+
}
|
|
122778
|
+
});
|
|
122779
|
+
}
|
|
122646
122780
|
directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
|
|
122647
122781
|
if (watcher.refCount === 0) {
|
|
122648
122782
|
directoryWatchesOfFailedLookups.delete(path);
|
|
@@ -122650,11 +122784,9 @@ var ts;
|
|
|
122650
122784
|
}
|
|
122651
122785
|
});
|
|
122652
122786
|
fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
|
|
122653
|
-
if (watcher.
|
|
122787
|
+
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122654
122788
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122655
122789
|
watcher.watcher.close();
|
|
122656
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122657
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122658
122790
|
}
|
|
122659
122791
|
});
|
|
122660
122792
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -122881,7 +123013,7 @@ var ts;
|
|
|
122881
123013
|
}
|
|
122882
123014
|
// If the directory is node_modules use it to watch, always watch it recursively
|
|
122883
123015
|
if (ts.isNodeModulesDirectory(dirPath)) {
|
|
122884
|
-
return
|
|
123016
|
+
return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
|
|
122885
123017
|
}
|
|
122886
123018
|
var nonRecursive = true;
|
|
122887
123019
|
// Use some ancestor of the root directory
|
|
@@ -122899,7 +123031,7 @@ var ts;
|
|
|
122899
123031
|
dir = ts.getDirectoryPath(dir);
|
|
122900
123032
|
}
|
|
122901
123033
|
}
|
|
122902
|
-
return
|
|
123034
|
+
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
|
|
122903
123035
|
}
|
|
122904
123036
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
122905
123037
|
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
@@ -122970,46 +123102,65 @@ var ts;
|
|
|
122970
123102
|
// Watch package json
|
|
122971
123103
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122972
123104
|
var affectingLocation = affectingLocations_1[_i];
|
|
122973
|
-
createFileWatcherOfAffectingLocation(affectingLocation);
|
|
123105
|
+
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
|
122974
123106
|
}
|
|
122975
123107
|
}
|
|
122976
|
-
function createFileWatcherOfAffectingLocation(affectingLocation) {
|
|
122977
|
-
var
|
|
122978
|
-
var fileWatcher = fileWatchesOfAffectingLocations.get(path);
|
|
123108
|
+
function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
|
|
123109
|
+
var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
122979
123110
|
if (fileWatcher) {
|
|
122980
|
-
|
|
123111
|
+
if (forResolution)
|
|
123112
|
+
fileWatcher.resolutions++;
|
|
123113
|
+
else
|
|
123114
|
+
fileWatcher.files++;
|
|
122981
123115
|
return;
|
|
122982
123116
|
}
|
|
122983
123117
|
var locationToWatch = affectingLocation;
|
|
122984
|
-
var locationToWatchPath = path;
|
|
122985
123118
|
if (resolutionHost.realpath) {
|
|
122986
123119
|
locationToWatch = resolutionHost.realpath(affectingLocation);
|
|
122987
|
-
|
|
122988
|
-
|
|
122989
|
-
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
|
|
123120
|
+
if (affectingLocation !== locationToWatch) {
|
|
123121
|
+
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
|
|
122990
123122
|
if (fileWatcher_1) {
|
|
122991
|
-
|
|
122992
|
-
|
|
122993
|
-
|
|
123123
|
+
if (forResolution)
|
|
123124
|
+
fileWatcher_1.resolutions++;
|
|
123125
|
+
else
|
|
123126
|
+
fileWatcher_1.files++;
|
|
123127
|
+
fileWatcher_1.paths.add(affectingLocation);
|
|
123128
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
|
|
122994
123129
|
return;
|
|
122995
123130
|
}
|
|
122996
123131
|
}
|
|
122997
123132
|
}
|
|
122998
123133
|
var paths = new ts.Set();
|
|
122999
|
-
paths.add(
|
|
123000
|
-
var
|
|
123001
|
-
|
|
123002
|
-
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName,
|
|
123003
|
-
|
|
123134
|
+
paths.add(locationToWatch);
|
|
123135
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123136
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123137
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123138
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123139
|
+
paths.forEach(function (path) {
|
|
123140
|
+
if (watcher.resolutions)
|
|
123141
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123142
|
+
if (watcher.files)
|
|
123143
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123144
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123145
|
+
});
|
|
123004
123146
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123005
|
-
})
|
|
123006
|
-
|
|
123147
|
+
}) : ts.noopFileWatcher;
|
|
123148
|
+
var watcher = {
|
|
123149
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123150
|
+
close: function () {
|
|
123151
|
+
actualWatcher.close();
|
|
123152
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123153
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123154
|
+
}
|
|
123155
|
+
} : actualWatcher,
|
|
123156
|
+
resolutions: forResolution ? 1 : 0,
|
|
123157
|
+
files: forResolution ? 0 : 1,
|
|
123007
123158
|
paths: paths,
|
|
123008
123159
|
};
|
|
123009
|
-
fileWatchesOfAffectingLocations.set(
|
|
123010
|
-
if (
|
|
123011
|
-
fileWatchesOfAffectingLocations.set(
|
|
123012
|
-
paths.add(
|
|
123160
|
+
fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
|
|
123161
|
+
if (affectingLocation !== locationToWatch) {
|
|
123162
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
|
|
123163
|
+
paths.add(affectingLocation);
|
|
123013
123164
|
}
|
|
123014
123165
|
}
|
|
123015
123166
|
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
|
|
@@ -123077,8 +123228,8 @@ var ts;
|
|
|
123077
123228
|
}
|
|
123078
123229
|
for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
|
|
123079
123230
|
var affectingLocation = affectingLocations_2[_a];
|
|
123080
|
-
var watcher = fileWatchesOfAffectingLocations.get(
|
|
123081
|
-
watcher.
|
|
123231
|
+
var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123232
|
+
watcher.resolutions--;
|
|
123082
123233
|
}
|
|
123083
123234
|
}
|
|
123084
123235
|
function removeDirectoryWatcher(dirPath) {
|
|
@@ -123132,7 +123283,7 @@ var ts;
|
|
|
123132
123283
|
resolution.isInvalidated = invalidated = true;
|
|
123133
123284
|
for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
|
|
123134
123285
|
var containingFilePath = _b[_a];
|
|
123135
|
-
(filesWithInvalidatedResolutions
|
|
123286
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
|
|
123136
123287
|
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
|
123137
123288
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
|
|
123138
123289
|
}
|
|
@@ -123199,10 +123350,25 @@ var ts;
|
|
|
123199
123350
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123200
123351
|
}
|
|
123201
123352
|
function invalidateResolutionsOfFailedLookupLocations() {
|
|
123353
|
+
var _a;
|
|
123354
|
+
var invalidated = false;
|
|
123355
|
+
if (affectingPathChecksForFile) {
|
|
123356
|
+
(_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
|
|
123357
|
+
if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
|
|
123358
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
|
|
123359
|
+
invalidated = true;
|
|
123360
|
+
}
|
|
123361
|
+
});
|
|
123362
|
+
affectingPathChecksForFile = undefined;
|
|
123363
|
+
}
|
|
123202
123364
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
|
123203
|
-
return
|
|
123365
|
+
return invalidated;
|
|
123366
|
+
}
|
|
123367
|
+
invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
|
|
123368
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123369
|
+
if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
|
|
123370
|
+
packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
|
|
123204
123371
|
}
|
|
123205
|
-
var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
|
|
123206
123372
|
failedLookupChecks = undefined;
|
|
123207
123373
|
startsWithPathChecks = undefined;
|
|
123208
123374
|
isInDirectoryChecks = undefined;
|
|
@@ -123215,17 +123381,15 @@ var ts;
|
|
|
123215
123381
|
return true;
|
|
123216
123382
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
|
|
123217
123383
|
return false;
|
|
123218
|
-
return resolution.failedLookupLocations.some(function (location) {
|
|
123219
|
-
|
|
123220
|
-
|
|
123221
|
-
|
|
123222
|
-
|
|
123223
|
-
|
|
123384
|
+
return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
|
|
123385
|
+
}
|
|
123386
|
+
function isInvalidatedFailedLookup(locationPath) {
|
|
123387
|
+
return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
|
|
123388
|
+
ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
|
|
123389
|
+
ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
|
|
123224
123390
|
}
|
|
123225
123391
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
123226
|
-
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
|
|
123227
|
-
return affectingPathChecks.has(resolutionHost.toPath(location));
|
|
123228
|
-
});
|
|
123392
|
+
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
|
|
123229
123393
|
}
|
|
123230
123394
|
function closeTypeRootsWatch() {
|
|
123231
123395
|
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
|
|
@@ -123291,7 +123455,7 @@ var ts;
|
|
|
123291
123455
|
function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
|
|
123292
123456
|
var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
|
|
123293
123457
|
var dirPath = resolutionHost.toPath(dir);
|
|
123294
|
-
return dirPath === rootPath ||
|
|
123458
|
+
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
123295
123459
|
}
|
|
123296
123460
|
}
|
|
123297
123461
|
ts.createResolutionCache = createResolutionCache;
|
|
@@ -123402,7 +123566,7 @@ var ts;
|
|
|
123402
123566
|
var info = getInfo(importingSourceFileName, host);
|
|
123403
123567
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123404
123568
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123405
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123569
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123406
123570
|
}
|
|
123407
123571
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123408
123572
|
if (options === void 0) { options = {}; }
|
|
@@ -123485,7 +123649,7 @@ var ts;
|
|
|
123485
123649
|
return nodeModulesSpecifiers;
|
|
123486
123650
|
}
|
|
123487
123651
|
if (!specifier && !modulePath.isRedirect) {
|
|
123488
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123652
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123489
123653
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123490
123654
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123491
123655
|
}
|
|
@@ -123513,7 +123677,7 @@ var ts;
|
|
|
123513
123677
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123514
123678
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123515
123679
|
}
|
|
123516
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123680
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123517
123681
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123518
123682
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123519
123683
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123527,9 +123691,8 @@ var ts;
|
|
|
123527
123691
|
if (!relativeToBaseUrl) {
|
|
123528
123692
|
return relativePath;
|
|
123529
123693
|
}
|
|
123530
|
-
var
|
|
123531
|
-
var
|
|
123532
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123694
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123695
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123533
123696
|
if (!nonRelative) {
|
|
123534
123697
|
return relativePath;
|
|
123535
123698
|
}
|
|
@@ -123764,28 +123927,102 @@ var ts;
|
|
|
123764
123927
|
return ambientModuleDeclare.name.text;
|
|
123765
123928
|
}
|
|
123766
123929
|
}
|
|
123767
|
-
function
|
|
123930
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
123931
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
123932
|
+
return [2 /* JsExtension */];
|
|
123933
|
+
}
|
|
123934
|
+
switch (preferredEnding) {
|
|
123935
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
123936
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
123937
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
123938
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
123939
|
+
}
|
|
123940
|
+
}
|
|
123941
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
123768
123942
|
for (var key in paths) {
|
|
123769
|
-
|
|
123770
|
-
var
|
|
123771
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
123943
|
+
var _loop_36 = function (patternText_1) {
|
|
123944
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
123772
123945
|
var indexOfStar = pattern.indexOf("*");
|
|
123946
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
123947
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
123948
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
123949
|
+
// and matches the '*'. For example:
|
|
123950
|
+
//
|
|
123951
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
123952
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
123953
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
123954
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
123955
|
+
//
|
|
123956
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
123957
|
+
//
|
|
123958
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
123959
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
123960
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
123961
|
+
// extension for a module specifier.)
|
|
123962
|
+
//
|
|
123963
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
123964
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
123965
|
+
//
|
|
123966
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
123967
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
123968
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
123969
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
123970
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
123971
|
+
// 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
|
|
123972
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
123973
|
+
//
|
|
123974
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
123975
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
123976
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
123977
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
123978
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
123979
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
123980
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
123981
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
123982
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
123983
|
+
ending: ending,
|
|
123984
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
123985
|
+
}); });
|
|
123986
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
123987
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
123988
|
+
}
|
|
123773
123989
|
if (indexOfStar !== -1) {
|
|
123774
|
-
var prefix = pattern.
|
|
123775
|
-
var suffix = pattern.
|
|
123776
|
-
|
|
123777
|
-
|
|
123778
|
-
|
|
123779
|
-
|
|
123780
|
-
|
|
123781
|
-
|
|
123990
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
123991
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
123992
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
123993
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
123994
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
123995
|
+
ts.startsWith(value, prefix) &&
|
|
123996
|
+
ts.endsWith(value, suffix) &&
|
|
123997
|
+
validateEnding({ ending: ending, value: value })) {
|
|
123998
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
123999
|
+
return { value: key.replace("*", matchedStar) };
|
|
124000
|
+
}
|
|
123782
124001
|
}
|
|
123783
124002
|
}
|
|
123784
|
-
else if (
|
|
123785
|
-
return
|
|
124003
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124004
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124005
|
+
return { value: key };
|
|
123786
124006
|
}
|
|
124007
|
+
};
|
|
124008
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124009
|
+
var patternText_1 = _a[_i];
|
|
124010
|
+
var state_12 = _loop_36(patternText_1);
|
|
124011
|
+
if (typeof state_12 === "object")
|
|
124012
|
+
return state_12.value;
|
|
123787
124013
|
}
|
|
123788
124014
|
}
|
|
124015
|
+
function validateEnding(_a) {
|
|
124016
|
+
var ending = _a.ending, value = _a.value;
|
|
124017
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124018
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124019
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124020
|
+
// 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
|
|
124021
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124022
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124023
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124024
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124025
|
+
}
|
|
123789
124026
|
}
|
|
123790
124027
|
var MatchingMode;
|
|
123791
124028
|
(function (MatchingMode) {
|
|
@@ -123881,10 +124118,10 @@ var ts;
|
|
|
123881
124118
|
return undefined;
|
|
123882
124119
|
}
|
|
123883
124120
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124121
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123884
124122
|
var moduleSpecifier = path;
|
|
123885
124123
|
var isPackageRootPath = false;
|
|
123886
124124
|
if (!packageNameOnly) {
|
|
123887
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123888
124125
|
var packageRootIndex = parts.packageRootIndex;
|
|
123889
124126
|
var moduleFileName = void 0;
|
|
123890
124127
|
while (true) {
|
|
@@ -123933,15 +124170,13 @@ var ts;
|
|
|
123933
124170
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
123934
124171
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
123935
124172
|
var moduleFileToTry = path;
|
|
124173
|
+
var maybeBlockedByTypesVersions = false;
|
|
123936
124174
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
123937
124175
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
123938
124176
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124177
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
123939
124178
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
123940
|
-
|
|
123941
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
123942
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
123943
|
-
// with, so for now we just stick with the mode of the file.
|
|
123944
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124179
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
123945
124180
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
123946
124181
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
123947
124182
|
: undefined;
|
|
@@ -123960,16 +124195,26 @@ var ts;
|
|
|
123960
124195
|
: undefined;
|
|
123961
124196
|
if (versionPaths) {
|
|
123962
124197
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
123963
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
123964
|
-
if (fromPaths
|
|
124198
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124199
|
+
if (fromPaths === undefined) {
|
|
124200
|
+
maybeBlockedByTypesVersions = true;
|
|
124201
|
+
}
|
|
124202
|
+
else {
|
|
123965
124203
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
123966
124204
|
}
|
|
123967
124205
|
}
|
|
123968
124206
|
// If the file is the main module, it can be imported by the package name
|
|
123969
124207
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
123970
|
-
if (ts.isString(mainFileRelative)) {
|
|
124208
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124209
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124210
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124211
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124212
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124213
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124214
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
123971
124215
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
123972
124216
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124217
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
123973
124218
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
123974
124219
|
}
|
|
123975
124220
|
}
|
|
@@ -124264,23 +124509,46 @@ var ts;
|
|
|
124264
124509
|
var file = _c[_i];
|
|
124265
124510
|
write("" + toFileName(file, relativeFileName));
|
|
124266
124511
|
(_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
|
|
124267
|
-
(_b =
|
|
124512
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
|
|
124268
124513
|
}
|
|
124269
124514
|
}
|
|
124270
124515
|
ts.explainFiles = explainFiles;
|
|
124271
|
-
function
|
|
124516
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
124517
|
+
var _a;
|
|
124272
124518
|
var result;
|
|
124273
124519
|
if (file.path !== file.resolvedPath) {
|
|
124274
|
-
(result
|
|
124520
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124275
124521
|
/*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
|
|
124276
124522
|
}
|
|
124277
124523
|
if (file.redirectInfo) {
|
|
124278
|
-
(result
|
|
124524
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124279
124525
|
/*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
|
|
124280
124526
|
}
|
|
124527
|
+
if (ts.isExternalOrCommonJsModule(file)) {
|
|
124528
|
+
switch (file.impliedNodeFormat) {
|
|
124529
|
+
case ts.ModuleKind.ESNext:
|
|
124530
|
+
if (file.packageJsonScope) {
|
|
124531
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124532
|
+
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124533
|
+
}
|
|
124534
|
+
break;
|
|
124535
|
+
case ts.ModuleKind.CommonJS:
|
|
124536
|
+
if (file.packageJsonScope) {
|
|
124537
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124538
|
+
/*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
|
|
124539
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
|
124540
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124541
|
+
}
|
|
124542
|
+
else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
124543
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124544
|
+
/*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
|
|
124545
|
+
}
|
|
124546
|
+
break;
|
|
124547
|
+
}
|
|
124548
|
+
}
|
|
124281
124549
|
return result;
|
|
124282
124550
|
}
|
|
124283
|
-
ts.
|
|
124551
|
+
ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
|
|
124284
124552
|
function getMatchedFileSpec(program, fileName) {
|
|
124285
124553
|
var _a;
|
|
124286
124554
|
var configFile = program.getCompilerOptions().configFile;
|
|
@@ -124490,6 +124758,7 @@ var ts;
|
|
|
124490
124758
|
MissingFile: "Missing file",
|
|
124491
124759
|
WildcardDirectory: "Wild card directory",
|
|
124492
124760
|
FailedLookupLocations: "Failed Lookup Locations",
|
|
124761
|
+
AffectingFileLocation: "File location affecting resolution",
|
|
124493
124762
|
TypeRoots: "Type roots",
|
|
124494
124763
|
ConfigFileOfReferencedProject: "Config file of referened project",
|
|
124495
124764
|
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
|
@@ -124813,7 +125082,7 @@ var ts;
|
|
|
124813
125082
|
compilerHost.getCompilationSettings = function () { return compilerOptions; };
|
|
124814
125083
|
compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
|
|
124815
125084
|
compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
|
|
124816
|
-
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.
|
|
125085
|
+
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
|
|
124817
125086
|
compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
|
|
124818
125087
|
compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
|
|
124819
125088
|
compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
|
|
@@ -124847,6 +125116,9 @@ var ts;
|
|
|
124847
125116
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
124848
125117
|
}) :
|
|
124849
125118
|
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
125119
|
+
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
|
125120
|
+
ts.maybeBind(host, host.getModuleResolutionCache) :
|
|
125121
|
+
(function () { return resolutionCache.getModuleResolutionCache(); });
|
|
124850
125122
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
124851
125123
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
124852
125124
|
synchronizeProgram();
|
|
@@ -124949,8 +125221,9 @@ var ts;
|
|
|
124949
125221
|
resolutionCache.startCachingPerDirectoryResolution();
|
|
124950
125222
|
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
|
|
124951
125223
|
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
|
125224
|
+
var oldProgram = getCurrentProgram();
|
|
124952
125225
|
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
124953
|
-
resolutionCache.finishCachingPerDirectoryResolution();
|
|
125226
|
+
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
|
124954
125227
|
// Update watches
|
|
124955
125228
|
ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
|
|
124956
125229
|
if (needsUpdateInTypeRootWatch) {
|
|
@@ -125032,9 +125305,6 @@ var ts;
|
|
|
125032
125305
|
sourceFilesCache.set(path, false);
|
|
125033
125306
|
}
|
|
125034
125307
|
}
|
|
125035
|
-
if (sourceFile) {
|
|
125036
|
-
sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
|
125037
|
-
}
|
|
125038
125308
|
return sourceFile;
|
|
125039
125309
|
}
|
|
125040
125310
|
return hostSourceFile.sourceFile;
|
|
@@ -125550,6 +125820,7 @@ var ts;
|
|
|
125550
125820
|
compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
|
|
125551
125821
|
compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
|
|
125552
125822
|
compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
125823
|
+
compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
|
|
125553
125824
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
125554
125825
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
125555
125826
|
if (!compilerHost.resolveModuleNames) {
|