typescript 5.5.0-dev.20240412 → 5.5.0-dev.20240413
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/tsc.js +405 -139
- package/lib/typescript.d.ts +97 -30
- package/lib/typescript.js +810 -364
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240413`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -4307,7 +4307,7 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4307
4307
|
const filePathComparer = getStringComparer(!useCaseSensitiveFileNames2);
|
|
4308
4308
|
const toCanonicalFilePath = createGetCanonicalFileName(useCaseSensitiveFileNames2);
|
|
4309
4309
|
return (dirName, callback, recursive, options) => recursive ? createDirectoryWatcher(dirName, options, callback) : watchDirectory(dirName, callback, recursive, options);
|
|
4310
|
-
function createDirectoryWatcher(dirName, options, callback) {
|
|
4310
|
+
function createDirectoryWatcher(dirName, options, callback, link) {
|
|
4311
4311
|
const dirPath = toCanonicalFilePath(dirName);
|
|
4312
4312
|
let directoryWatcher = cache.get(dirPath);
|
|
4313
4313
|
if (directoryWatcher) {
|
|
@@ -4317,10 +4317,12 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4317
4317
|
watcher: watchDirectory(
|
|
4318
4318
|
dirName,
|
|
4319
4319
|
(fileName) => {
|
|
4320
|
+
var _a;
|
|
4320
4321
|
if (isIgnoredPath(fileName, options))
|
|
4321
4322
|
return;
|
|
4322
4323
|
if (options == null ? void 0 : options.synchronousWatchDirectory) {
|
|
4323
|
-
|
|
4324
|
+
if (!((_a = cache.get(dirPath)) == null ? void 0 : _a.targetWatcher))
|
|
4325
|
+
invokeCallbacks(dirName, dirPath, fileName);
|
|
4324
4326
|
updateChildWatches(dirName, dirPath, options);
|
|
4325
4327
|
} else {
|
|
4326
4328
|
nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
|
|
@@ -4331,11 +4333,15 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4331
4333
|
options
|
|
4332
4334
|
),
|
|
4333
4335
|
refCount: 1,
|
|
4334
|
-
childWatches: emptyArray
|
|
4336
|
+
childWatches: emptyArray,
|
|
4337
|
+
targetWatcher: void 0,
|
|
4338
|
+
links: void 0
|
|
4335
4339
|
};
|
|
4336
4340
|
cache.set(dirPath, directoryWatcher);
|
|
4337
4341
|
updateChildWatches(dirName, dirPath, options);
|
|
4338
4342
|
}
|
|
4343
|
+
if (link)
|
|
4344
|
+
(directoryWatcher.links ?? (directoryWatcher.links = /* @__PURE__ */ new Set())).add(link);
|
|
4339
4345
|
const callbackToAdd = callback && { dirName, callback };
|
|
4340
4346
|
if (callbackToAdd) {
|
|
4341
4347
|
callbackCache.add(dirPath, callbackToAdd);
|
|
@@ -4343,19 +4349,25 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4343
4349
|
return {
|
|
4344
4350
|
dirName,
|
|
4345
4351
|
close: () => {
|
|
4352
|
+
var _a;
|
|
4346
4353
|
const directoryWatcher2 = Debug.checkDefined(cache.get(dirPath));
|
|
4347
4354
|
if (callbackToAdd)
|
|
4348
4355
|
callbackCache.remove(dirPath, callbackToAdd);
|
|
4356
|
+
if (link)
|
|
4357
|
+
(_a = directoryWatcher2.links) == null ? void 0 : _a.delete(link);
|
|
4349
4358
|
directoryWatcher2.refCount--;
|
|
4350
4359
|
if (directoryWatcher2.refCount)
|
|
4351
4360
|
return;
|
|
4352
4361
|
cache.delete(dirPath);
|
|
4362
|
+
directoryWatcher2.links = void 0;
|
|
4353
4363
|
closeFileWatcherOf(directoryWatcher2);
|
|
4364
|
+
closeTargetWatcher(directoryWatcher2);
|
|
4354
4365
|
directoryWatcher2.childWatches.forEach(closeFileWatcher);
|
|
4355
4366
|
}
|
|
4356
4367
|
};
|
|
4357
4368
|
}
|
|
4358
|
-
function invokeCallbacks(dirPath, fileNameOrInvokeMap, fileNames) {
|
|
4369
|
+
function invokeCallbacks(dirName, dirPath, fileNameOrInvokeMap, fileNames) {
|
|
4370
|
+
var _a, _b;
|
|
4359
4371
|
let fileName;
|
|
4360
4372
|
let invokeMap;
|
|
4361
4373
|
if (isString(fileNameOrInvokeMap)) {
|
|
@@ -4383,6 +4395,14 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4383
4395
|
}
|
|
4384
4396
|
}
|
|
4385
4397
|
});
|
|
4398
|
+
(_b = (_a = cache.get(dirPath)) == null ? void 0 : _a.links) == null ? void 0 : _b.forEach((link) => {
|
|
4399
|
+
const toPathInLink = (fileName2) => combinePaths(link, getRelativePathFromDirectory(dirName, fileName2, toCanonicalFilePath));
|
|
4400
|
+
if (invokeMap) {
|
|
4401
|
+
invokeCallbacks(link, toCanonicalFilePath(link), invokeMap, fileNames == null ? void 0 : fileNames.map(toPathInLink));
|
|
4402
|
+
} else {
|
|
4403
|
+
invokeCallbacks(link, toCanonicalFilePath(link), toPathInLink(fileName));
|
|
4404
|
+
}
|
|
4405
|
+
});
|
|
4386
4406
|
}
|
|
4387
4407
|
function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
|
|
4388
4408
|
const parentWatcher = cache.get(dirPath);
|
|
@@ -4390,7 +4410,8 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4390
4410
|
scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
|
|
4391
4411
|
return;
|
|
4392
4412
|
}
|
|
4393
|
-
invokeCallbacks(dirPath, fileName);
|
|
4413
|
+
invokeCallbacks(dirName, dirPath, fileName);
|
|
4414
|
+
closeTargetWatcher(parentWatcher);
|
|
4394
4415
|
removeChildWatches(parentWatcher);
|
|
4395
4416
|
}
|
|
4396
4417
|
function scheduleUpdateChildWatches(dirName, dirPath, fileName, options) {
|
|
@@ -4407,6 +4428,7 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4407
4428
|
timerToUpdateChildWatches = setTimeout2(onTimerToUpdateChildWatches, 1e3, "timerToUpdateChildWatches");
|
|
4408
4429
|
}
|
|
4409
4430
|
function onTimerToUpdateChildWatches() {
|
|
4431
|
+
var _a;
|
|
4410
4432
|
timerToUpdateChildWatches = void 0;
|
|
4411
4433
|
sysLog(`sysLog:: onTimerToUpdateChildWatches:: ${cacheToUpdateChildWatches.size}`);
|
|
4412
4434
|
const start = timestamp();
|
|
@@ -4417,7 +4439,8 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4417
4439
|
const { value: [dirPath, { dirName, options, fileNames }] } = result;
|
|
4418
4440
|
cacheToUpdateChildWatches.delete(dirPath);
|
|
4419
4441
|
const hasChanges = updateChildWatches(dirName, dirPath, options);
|
|
4420
|
-
|
|
4442
|
+
if (!((_a = cache.get(dirPath)) == null ? void 0 : _a.targetWatcher))
|
|
4443
|
+
invokeCallbacks(dirName, dirPath, invokeMap, hasChanges ? void 0 : fileNames);
|
|
4421
4444
|
}
|
|
4422
4445
|
sysLog(`sysLog:: invokingWatchers:: Elapsed:: ${timestamp() - start}ms:: ${cacheToUpdateChildWatches.size}`);
|
|
4423
4446
|
callbackCache.forEach((callbacks, rootDirName) => {
|
|
@@ -4445,22 +4468,46 @@ function createDirectoryWatcherSupportingRecursive({
|
|
|
4445
4468
|
removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
|
|
4446
4469
|
}
|
|
4447
4470
|
}
|
|
4471
|
+
function closeTargetWatcher(watcher) {
|
|
4472
|
+
if (watcher == null ? void 0 : watcher.targetWatcher) {
|
|
4473
|
+
watcher.targetWatcher.close();
|
|
4474
|
+
watcher.targetWatcher = void 0;
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4448
4477
|
function updateChildWatches(parentDir, parentDirPath, options) {
|
|
4449
4478
|
const parentWatcher = cache.get(parentDirPath);
|
|
4450
4479
|
if (!parentWatcher)
|
|
4451
4480
|
return false;
|
|
4481
|
+
const target = normalizePath(realpath(parentDir));
|
|
4482
|
+
let hasChanges;
|
|
4452
4483
|
let newChildWatches;
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4484
|
+
if (filePathComparer(target, parentDir) === 0 /* EqualTo */) {
|
|
4485
|
+
hasChanges = enumerateInsertsAndDeletes(
|
|
4486
|
+
fileSystemEntryExists(parentDir, 1 /* Directory */) ? mapDefined(getAccessibleSortedChildDirectories(parentDir), (child) => {
|
|
4487
|
+
const childFullName = getNormalizedAbsolutePath(child, parentDir);
|
|
4488
|
+
return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : void 0;
|
|
4489
|
+
}) : emptyArray,
|
|
4490
|
+
parentWatcher.childWatches,
|
|
4491
|
+
(child, childWatcher) => filePathComparer(child, childWatcher.dirName),
|
|
4492
|
+
createAndAddChildDirectoryWatcher,
|
|
4493
|
+
closeFileWatcher,
|
|
4494
|
+
addChildDirectoryWatcher
|
|
4495
|
+
);
|
|
4496
|
+
} else if (parentWatcher.targetWatcher && filePathComparer(target, parentWatcher.targetWatcher.dirName) === 0 /* EqualTo */) {
|
|
4497
|
+
hasChanges = false;
|
|
4498
|
+
Debug.assert(parentWatcher.childWatches === emptyArray);
|
|
4499
|
+
} else {
|
|
4500
|
+
closeTargetWatcher(parentWatcher);
|
|
4501
|
+
parentWatcher.targetWatcher = createDirectoryWatcher(
|
|
4502
|
+
target,
|
|
4503
|
+
options,
|
|
4504
|
+
/*callback*/
|
|
4505
|
+
void 0,
|
|
4506
|
+
parentDir
|
|
4507
|
+
);
|
|
4508
|
+
parentWatcher.childWatches.forEach(closeFileWatcher);
|
|
4509
|
+
hasChanges = true;
|
|
4510
|
+
}
|
|
4464
4511
|
parentWatcher.childWatches = newChildWatches || emptyArray;
|
|
4465
4512
|
return hasChanges;
|
|
4466
4513
|
function createAndAddChildDirectoryWatcher(childName) {
|
|
@@ -5955,6 +6002,7 @@ var Diagnostics = {
|
|
|
5955
6002
|
_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
|
5956
6003
|
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
|
|
5957
6004
|
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
|
6005
|
+
ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve: diag(1293, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve_1293", "ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'."),
|
|
5958
6006
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
5959
6007
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
5960
6008
|
The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
|
|
@@ -13709,6 +13757,23 @@ function isFunctionSymbol(symbol) {
|
|
|
13709
13757
|
const decl = symbol.valueDeclaration;
|
|
13710
13758
|
return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
|
|
13711
13759
|
}
|
|
13760
|
+
function canHaveModuleSpecifier(node) {
|
|
13761
|
+
switch (node == null ? void 0 : node.kind) {
|
|
13762
|
+
case 260 /* VariableDeclaration */:
|
|
13763
|
+
case 208 /* BindingElement */:
|
|
13764
|
+
case 272 /* ImportDeclaration */:
|
|
13765
|
+
case 278 /* ExportDeclaration */:
|
|
13766
|
+
case 271 /* ImportEqualsDeclaration */:
|
|
13767
|
+
case 273 /* ImportClause */:
|
|
13768
|
+
case 280 /* NamespaceExport */:
|
|
13769
|
+
case 274 /* NamespaceImport */:
|
|
13770
|
+
case 281 /* ExportSpecifier */:
|
|
13771
|
+
case 276 /* ImportSpecifier */:
|
|
13772
|
+
case 205 /* ImportType */:
|
|
13773
|
+
return true;
|
|
13774
|
+
}
|
|
13775
|
+
return false;
|
|
13776
|
+
}
|
|
13712
13777
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
13713
13778
|
var _a, _b;
|
|
13714
13779
|
switch (node.kind) {
|
|
@@ -16383,8 +16448,8 @@ function walkTreeForJSXTags(node) {
|
|
|
16383
16448
|
function isFileModuleFromUsingJSXTag(file) {
|
|
16384
16449
|
return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
|
|
16385
16450
|
}
|
|
16386
|
-
function isFileForcedToBeModuleByFormat(file) {
|
|
16387
|
-
return (file
|
|
16451
|
+
function isFileForcedToBeModuleByFormat(file, options) {
|
|
16452
|
+
return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
|
|
16388
16453
|
}
|
|
16389
16454
|
function getSetExternalModuleIndicator(options) {
|
|
16390
16455
|
switch (getEmitModuleDetectionKind(options)) {
|
|
@@ -16403,10 +16468,14 @@ function getSetExternalModuleIndicator(options) {
|
|
|
16403
16468
|
}
|
|
16404
16469
|
checks.push(isFileForcedToBeModuleByFormat);
|
|
16405
16470
|
const combined = or(...checks);
|
|
16406
|
-
const callback = (file) => void (file.externalModuleIndicator = combined(file));
|
|
16471
|
+
const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
|
|
16407
16472
|
return callback;
|
|
16408
16473
|
}
|
|
16409
16474
|
}
|
|
16475
|
+
function importSyntaxAffectsModuleResolution(options) {
|
|
16476
|
+
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
16477
|
+
return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
|
|
16478
|
+
}
|
|
16410
16479
|
function createComputedCompilerOptions(options) {
|
|
16411
16480
|
return options;
|
|
16412
16481
|
}
|
|
@@ -25550,7 +25619,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
|
|
|
25550
25619
|
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
25551
25620
|
let namedBindings;
|
|
25552
25621
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
25553
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile
|
|
25622
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
|
|
25554
25623
|
const helpers = getEmitHelpers(sourceFile);
|
|
25555
25624
|
if (helpers) {
|
|
25556
25625
|
const helperNames = [];
|
|
@@ -25615,8 +25684,7 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
|
|
|
25615
25684
|
if (externalHelpersModuleName) {
|
|
25616
25685
|
return externalHelpersModuleName;
|
|
25617
25686
|
}
|
|
25618
|
-
|
|
25619
|
-
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
|
|
25687
|
+
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
|
|
25620
25688
|
if (!create) {
|
|
25621
25689
|
const helpers = getEmitHelpers(node);
|
|
25622
25690
|
if (helpers) {
|
|
@@ -43011,13 +43079,15 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
|
|
|
43011
43079
|
}
|
|
43012
43080
|
|
|
43013
43081
|
// src/compiler/moduleSpecifiers.ts
|
|
43014
|
-
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
|
43082
|
+
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, host, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
|
43015
43083
|
const filePreferredEnding = getPreferredEnding();
|
|
43016
43084
|
return {
|
|
43017
43085
|
relativePreference: oldImportSpecifier !== void 0 ? isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */ : importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */,
|
|
43018
43086
|
getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
|
|
43019
|
-
const
|
|
43020
|
-
|
|
43087
|
+
const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
|
|
43088
|
+
const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
|
43089
|
+
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
43090
|
+
if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
|
|
43021
43091
|
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
|
43022
43092
|
return [3 /* TsExtension */, 2 /* JsExtension */];
|
|
43023
43093
|
}
|
|
@@ -43050,7 +43120,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
|
|
|
43050
43120
|
}
|
|
43051
43121
|
return getModuleSpecifierEndingPreference(
|
|
43052
43122
|
importModuleSpecifierEnding,
|
|
43053
|
-
resolutionMode ?? importingSourceFile
|
|
43123
|
+
resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
|
|
43054
43124
|
compilerOptions,
|
|
43055
43125
|
isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
|
|
43056
43126
|
);
|
|
@@ -43111,14 +43181,17 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
|
|
43111
43181
|
}
|
|
43112
43182
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
43113
43183
|
const info = getInfo(importingSourceFile.fileName, host);
|
|
43114
|
-
const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
43184
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
|
|
43115
43185
|
const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
|
|
43116
43186
|
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
|
43117
43187
|
(reason) => {
|
|
43118
43188
|
if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path)
|
|
43119
43189
|
return void 0;
|
|
43120
|
-
|
|
43190
|
+
const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
|
|
43191
|
+
const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
|
|
43192
|
+
if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
|
|
43121
43193
|
return void 0;
|
|
43194
|
+
}
|
|
43122
43195
|
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
|
43123
43196
|
return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
|
|
43124
43197
|
}
|
|
@@ -43613,7 +43686,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
43613
43686
|
if (!parts) {
|
|
43614
43687
|
return void 0;
|
|
43615
43688
|
}
|
|
43616
|
-
const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
|
|
43689
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
|
|
43617
43690
|
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
|
43618
43691
|
let moduleSpecifier = path;
|
|
43619
43692
|
let isPackageRootPath = false;
|
|
@@ -43664,7 +43737,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
43664
43737
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
43665
43738
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
|
43666
43739
|
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
43667
|
-
const importMode = overrideMode || importingSourceFile
|
|
43740
|
+
const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
|
|
43668
43741
|
if (getResolvePackageJsonExports(options)) {
|
|
43669
43742
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
|
43670
43743
|
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
|
@@ -43816,6 +43889,9 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
|
|
|
43816
43889
|
function isPathRelativeToParent(path) {
|
|
43817
43890
|
return startsWith(path, "..");
|
|
43818
43891
|
}
|
|
43892
|
+
function getDefaultResolutionModeForFile(file, host, compilerOptions) {
|
|
43893
|
+
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
|
43894
|
+
}
|
|
43819
43895
|
|
|
43820
43896
|
// src/compiler/checker.ts
|
|
43821
43897
|
var ambientModuleSymbolRegex = /^".+"$/;
|
|
@@ -46037,22 +46113,28 @@ function createTypeChecker(host) {
|
|
|
46037
46113
|
function isSyntacticDefault(node) {
|
|
46038
46114
|
return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
|
|
46039
46115
|
}
|
|
46040
|
-
function
|
|
46041
|
-
return isStringLiteralLike(usage) ? host.
|
|
46116
|
+
function getEmitSyntaxForModuleSpecifierExpression(usage) {
|
|
46117
|
+
return isStringLiteralLike(usage) ? host.getEmitSyntaxForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
|
46042
46118
|
}
|
|
46043
46119
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
46044
46120
|
return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
|
|
46045
46121
|
}
|
|
46046
|
-
function
|
|
46047
|
-
|
|
46048
|
-
|
|
46122
|
+
function isOnlyImportableAsDefault(usage) {
|
|
46123
|
+
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
46124
|
+
const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
|
|
46125
|
+
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
|
46126
|
+
}
|
|
46127
|
+
return false;
|
|
46049
46128
|
}
|
|
46050
46129
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
46051
|
-
const usageMode = file &&
|
|
46052
|
-
if (file && usageMode !== void 0
|
|
46053
|
-
const
|
|
46054
|
-
if (usageMode === 99 /* ESNext */
|
|
46055
|
-
return
|
|
46130
|
+
const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
|
|
46131
|
+
if (file && usageMode !== void 0) {
|
|
46132
|
+
const targetMode = host.getImpliedNodeFormatForEmit(file);
|
|
46133
|
+
if (usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */ && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
46134
|
+
return true;
|
|
46135
|
+
}
|
|
46136
|
+
if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
|
|
46137
|
+
return false;
|
|
46056
46138
|
}
|
|
46057
46139
|
}
|
|
46058
46140
|
if (!allowSyntheticDefaultImports) {
|
|
@@ -46111,7 +46193,7 @@ function createTypeChecker(host) {
|
|
|
46111
46193
|
if (!specifier) {
|
|
46112
46194
|
return exportDefaultSymbol;
|
|
46113
46195
|
}
|
|
46114
|
-
const hasDefaultOnly =
|
|
46196
|
+
const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
|
|
46115
46197
|
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
|
46116
46198
|
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
46117
46199
|
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
|
|
@@ -46315,7 +46397,7 @@ function createTypeChecker(host) {
|
|
|
46315
46397
|
let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
46316
46398
|
if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
|
|
46317
46399
|
const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
46318
|
-
if (
|
|
46400
|
+
if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
46319
46401
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
46320
46402
|
}
|
|
46321
46403
|
}
|
|
@@ -46945,7 +47027,7 @@ function createTypeChecker(host) {
|
|
|
46945
47027
|
/*requireStringLiteralLikeArgument*/
|
|
46946
47028
|
true
|
|
46947
47029
|
) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, isImportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression) || ((_f = findAncestor(location, isExportDeclaration)) == null ? void 0 : _f.moduleSpecifier);
|
|
46948
|
-
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile
|
|
47030
|
+
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
|
|
46949
47031
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
46950
47032
|
const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
|
|
46951
47033
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
@@ -47190,7 +47272,7 @@ function createTypeChecker(host) {
|
|
|
47190
47272
|
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
47191
47273
|
}
|
|
47192
47274
|
const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
47193
|
-
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(
|
|
47275
|
+
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), host.getImpliedNodeFormatForEmit(targetFile));
|
|
47194
47276
|
if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
|
|
47195
47277
|
let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
47196
47278
|
if (!sigs || !sigs.length) {
|
|
@@ -49743,14 +49825,16 @@ function createTypeChecker(host) {
|
|
|
49743
49825
|
return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
|
|
49744
49826
|
}
|
|
49745
49827
|
}
|
|
49746
|
-
if (!context.
|
|
49828
|
+
if (!context.enclosingFile || !context.tracker.moduleResolverHost) {
|
|
49747
49829
|
if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
|
|
49748
49830
|
return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
|
|
49749
49831
|
}
|
|
49750
49832
|
return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
|
|
49751
49833
|
}
|
|
49752
|
-
const
|
|
49753
|
-
const
|
|
49834
|
+
const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
|
|
49835
|
+
const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
|
|
49836
|
+
const contextFile = context.enclosingFile;
|
|
49837
|
+
const resolutionMode = overrideImportMode || originalModuleSpecifier && host.getModeForUsageLocation(contextFile, originalModuleSpecifier) || contextFile && host.getDefaultResolutionModeForFile(contextFile);
|
|
49754
49838
|
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
|
49755
49839
|
const links = getSymbolLinks(symbol);
|
|
49756
49840
|
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
|
@@ -50486,22 +50570,16 @@ function createTypeChecker(host) {
|
|
|
50486
50570
|
return p.name && isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? `args` : `arg${index}`;
|
|
50487
50571
|
}
|
|
50488
50572
|
function rewriteModuleSpecifier(parent, lit) {
|
|
50489
|
-
if (context.bundled) {
|
|
50490
|
-
|
|
50491
|
-
|
|
50492
|
-
|
|
50493
|
-
|
|
50494
|
-
|
|
50495
|
-
getCanonicalFileName,
|
|
50496
|
-
getCurrentDirectory: () => context.tracker.moduleResolverHost.getCurrentDirectory(),
|
|
50497
|
-
getCommonSourceDirectory: () => context.tracker.moduleResolverHost.getCommonSourceDirectory()
|
|
50498
|
-
};
|
|
50499
|
-
const newName = getResolvedExternalModuleName(resolverHost, targetFile);
|
|
50500
|
-
return factory.createStringLiteral(newName);
|
|
50573
|
+
if (context.bundled || context.enclosingFile !== getSourceFileOfNode(lit)) {
|
|
50574
|
+
const targetFile = getExternalModuleFileFromDeclaration(parent);
|
|
50575
|
+
if (targetFile) {
|
|
50576
|
+
const newName = getSpecifierForModuleSymbol(targetFile.symbol, context);
|
|
50577
|
+
if (newName !== lit.text) {
|
|
50578
|
+
return setOriginalNode(factory.createStringLiteral(newName), lit);
|
|
50501
50579
|
}
|
|
50502
50580
|
}
|
|
50503
50581
|
}
|
|
50504
|
-
return lit;
|
|
50582
|
+
return visitNode(lit, visitExistingNodeTreeSymbols, isStringLiteral);
|
|
50505
50583
|
}
|
|
50506
50584
|
}
|
|
50507
50585
|
}
|
|
@@ -72592,6 +72670,7 @@ function createTypeChecker(host) {
|
|
|
72592
72670
|
candidateForTypeArgumentError = oldCandidateForTypeArgumentError;
|
|
72593
72671
|
}
|
|
72594
72672
|
function chooseOverload(candidates2, relation, isSingleNonGenericCandidate2, signatureHelpTrailingComma2 = false) {
|
|
72673
|
+
var _a, _b;
|
|
72595
72674
|
candidatesForArgumentError = void 0;
|
|
72596
72675
|
candidateForArgumentArityError = void 0;
|
|
72597
72676
|
candidateForTypeArgumentError = void 0;
|
|
@@ -72626,7 +72705,9 @@ function createTypeChecker(host) {
|
|
|
72626
72705
|
let checkCandidate;
|
|
72627
72706
|
let inferenceContext;
|
|
72628
72707
|
if (candidate.typeParameters) {
|
|
72629
|
-
|
|
72708
|
+
const paramLocation = (_b = (_a = candidate.typeParameters[0].symbol.declarations) == null ? void 0 : _a[0]) == null ? void 0 : _b.parent;
|
|
72709
|
+
const candidateParameterContext = paramLocation || (candidate.declaration && isConstructorDeclaration(candidate.declaration) ? candidate.declaration.parent : candidate.declaration);
|
|
72710
|
+
if (candidateParameterContext && findAncestor(node, (a) => a === candidateParameterContext)) {
|
|
72630
72711
|
candidate = getImplementationSignature(candidate);
|
|
72631
72712
|
}
|
|
72632
72713
|
let typeArgumentTypes;
|
|
@@ -73572,7 +73653,7 @@ function createTypeChecker(host) {
|
|
|
73572
73653
|
return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
|
|
73573
73654
|
}
|
|
73574
73655
|
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
73575
|
-
const hasDefaultOnly =
|
|
73656
|
+
const hasDefaultOnly = isOnlyImportableAsDefault(moduleSpecifier);
|
|
73576
73657
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
73577
73658
|
const synthType = type;
|
|
73578
73659
|
if (!synthType.defaultOnlyType) {
|
|
@@ -78909,7 +78990,7 @@ function createTypeChecker(host) {
|
|
|
78909
78990
|
});
|
|
78910
78991
|
}
|
|
78911
78992
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
78912
|
-
if (
|
|
78993
|
+
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) >= 5 /* ES2015 */) {
|
|
78913
78994
|
return;
|
|
78914
78995
|
}
|
|
78915
78996
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -80338,7 +80419,7 @@ function createTypeChecker(host) {
|
|
|
80338
80419
|
}
|
|
80339
80420
|
}
|
|
80340
80421
|
function checkClassNameCollisionWithObject(name) {
|
|
80341
|
-
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (
|
|
80422
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < 5 /* ES2015 */) {
|
|
80342
80423
|
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
|
80343
80424
|
}
|
|
80344
80425
|
}
|
|
@@ -81408,7 +81489,7 @@ function createTypeChecker(host) {
|
|
|
81408
81489
|
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
|
81409
81490
|
}
|
|
81410
81491
|
}
|
|
81411
|
-
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (
|
|
81492
|
+
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(node.parent) === 1 /* CommonJS */) {
|
|
81412
81493
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
|
81413
81494
|
if (exportModifier) {
|
|
81414
81495
|
error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
@@ -81618,8 +81699,10 @@ function createTypeChecker(host) {
|
|
|
81618
81699
|
}
|
|
81619
81700
|
}
|
|
81620
81701
|
}
|
|
81621
|
-
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (
|
|
81702
|
+
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
81622
81703
|
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
81704
|
+
} else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
81705
|
+
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
|
|
81623
81706
|
}
|
|
81624
81707
|
}
|
|
81625
81708
|
if (isImportSpecifier(node)) {
|
|
@@ -81661,7 +81744,7 @@ function createTypeChecker(host) {
|
|
|
81661
81744
|
function checkImportBinding(node) {
|
|
81662
81745
|
checkCollisionsForDeclarationName(node, node.name);
|
|
81663
81746
|
checkAliasSymbol(node);
|
|
81664
|
-
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) &&
|
|
81747
|
+
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
|
|
81665
81748
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81666
81749
|
}
|
|
81667
81750
|
}
|
|
@@ -81682,7 +81765,7 @@ function createTypeChecker(host) {
|
|
|
81682
81765
|
if (validForTypeAttributes && override) {
|
|
81683
81766
|
return;
|
|
81684
81767
|
}
|
|
81685
|
-
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier &&
|
|
81768
|
+
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
|
|
81686
81769
|
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
|
81687
81770
|
const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
|
|
81688
81771
|
return grammarErrorOnNode(node, message);
|
|
@@ -81715,7 +81798,7 @@ function createTypeChecker(host) {
|
|
|
81715
81798
|
if (importClause.namedBindings) {
|
|
81716
81799
|
if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
|
|
81717
81800
|
checkImportBinding(importClause.namedBindings);
|
|
81718
|
-
if (
|
|
81801
|
+
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && getESModuleInterop(compilerOptions)) {
|
|
81719
81802
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81720
81803
|
}
|
|
81721
81804
|
} else {
|
|
@@ -81757,7 +81840,7 @@ function createTypeChecker(host) {
|
|
|
81757
81840
|
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
|
81758
81841
|
}
|
|
81759
81842
|
} else {
|
|
81760
|
-
if (
|
|
81843
|
+
if (5 /* ES2015 */ <= moduleKind && moduleKind <= 99 /* ESNext */ && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
81761
81844
|
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
|
81762
81845
|
}
|
|
81763
81846
|
}
|
|
@@ -81786,7 +81869,7 @@ function createTypeChecker(host) {
|
|
|
81786
81869
|
} else if (node.exportClause) {
|
|
81787
81870
|
checkAliasSymbol(node.exportClause);
|
|
81788
81871
|
}
|
|
81789
|
-
if (
|
|
81872
|
+
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
|
|
81790
81873
|
if (node.exportClause) {
|
|
81791
81874
|
if (getESModuleInterop(compilerOptions)) {
|
|
81792
81875
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
@@ -81845,7 +81928,7 @@ function createTypeChecker(host) {
|
|
|
81845
81928
|
}
|
|
81846
81929
|
}
|
|
81847
81930
|
} else {
|
|
81848
|
-
if (getESModuleInterop(compilerOptions) &&
|
|
81931
|
+
if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
|
|
81849
81932
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81850
81933
|
}
|
|
81851
81934
|
}
|
|
@@ -81871,7 +81954,7 @@ function createTypeChecker(host) {
|
|
|
81871
81954
|
if (typeAnnotationNode) {
|
|
81872
81955
|
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
|
|
81873
81956
|
}
|
|
81874
|
-
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (
|
|
81957
|
+
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */;
|
|
81875
81958
|
if (node.expression.kind === 80 /* Identifier */) {
|
|
81876
81959
|
const id = node.expression;
|
|
81877
81960
|
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
|
@@ -81951,7 +82034,7 @@ function createTypeChecker(host) {
|
|
|
81951
82034
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
81952
82035
|
}
|
|
81953
82036
|
if (node.isExportEquals) {
|
|
81954
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node)
|
|
82037
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) !== 1 /* CommonJS */)) {
|
|
81955
82038
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
81956
82039
|
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
|
81957
82040
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
@@ -84332,7 +84415,7 @@ function createTypeChecker(host) {
|
|
|
84332
84415
|
break;
|
|
84333
84416
|
case 95 /* ExportKeyword */:
|
|
84334
84417
|
if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later
|
|
84335
|
-
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (
|
|
84418
|
+
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
84336
84419
|
return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
84337
84420
|
}
|
|
84338
84421
|
if (flags & 32 /* Export */) {
|
|
@@ -85243,7 +85326,7 @@ function createTypeChecker(host) {
|
|
|
85243
85326
|
const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
|
85244
85327
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
85245
85328
|
}
|
|
85246
|
-
if ((
|
|
85329
|
+
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
|
|
85247
85330
|
checkESModuleMarker(node.name);
|
|
85248
85331
|
}
|
|
85249
85332
|
return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
|
|
@@ -85730,7 +85813,9 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
|
|
|
85730
85813
|
isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
|
|
85731
85814
|
fileExists: (fileName) => host.fileExists(fileName),
|
|
85732
85815
|
getFileIncludeReasons: () => host.getFileIncludeReasons(),
|
|
85733
|
-
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
85816
|
+
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
|
|
85817
|
+
getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
|
|
85818
|
+
getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
|
|
85734
85819
|
};
|
|
85735
85820
|
}
|
|
85736
85821
|
var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
|
@@ -104976,6 +105061,9 @@ function transformModule(context) {
|
|
|
104976
105061
|
return updated;
|
|
104977
105062
|
}
|
|
104978
105063
|
function shouldEmitUnderscoreUnderscoreESModule() {
|
|
105064
|
+
if (hasJSFileExtension(currentSourceFile.fileName) && currentSourceFile.commonJsModuleIndicator && (!currentSourceFile.externalModuleIndicator || currentSourceFile.externalModuleIndicator === true)) {
|
|
105065
|
+
return false;
|
|
105066
|
+
}
|
|
104979
105067
|
if (!currentModuleInfo.exportEquals && isExternalModule(currentSourceFile)) {
|
|
104980
105068
|
return true;
|
|
104981
105069
|
}
|
|
@@ -105454,7 +105542,7 @@ function transformModule(context) {
|
|
|
105454
105542
|
case 354 /* PartiallyEmittedExpression */:
|
|
105455
105543
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
105456
105544
|
case 213 /* CallExpression */:
|
|
105457
|
-
if (isImportCall(node) && currentSourceFile
|
|
105545
|
+
if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
|
|
105458
105546
|
return visitImportCallExpression(node);
|
|
105459
105547
|
}
|
|
105460
105548
|
break;
|
|
@@ -108455,8 +108543,8 @@ function transformECMAScriptModule(context) {
|
|
|
108455
108543
|
}
|
|
108456
108544
|
}
|
|
108457
108545
|
|
|
108458
|
-
// src/compiler/transformers/module/
|
|
108459
|
-
function
|
|
108546
|
+
// src/compiler/transformers/module/impliedNodeFormatDependent.ts
|
|
108547
|
+
function transformImpliedNodeFormatDependentModule(context) {
|
|
108460
108548
|
const previousOnSubstituteNode = context.onSubstituteNode;
|
|
108461
108549
|
const previousOnEmitNode = context.onEmitNode;
|
|
108462
108550
|
const esmTransform = transformECMAScriptModule(context);
|
|
@@ -108467,6 +108555,7 @@ function transformNodeModule(context) {
|
|
|
108467
108555
|
const cjsTransform = transformModule(context);
|
|
108468
108556
|
const cjsOnSubstituteNode = context.onSubstituteNode;
|
|
108469
108557
|
const cjsOnEmitNode = context.onEmitNode;
|
|
108558
|
+
const getEmitModuleFormatOfFile = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
|
108470
108559
|
context.onSubstituteNode = onSubstituteNode;
|
|
108471
108560
|
context.onEmitNode = onEmitNode;
|
|
108472
108561
|
context.enableSubstitution(307 /* SourceFile */);
|
|
@@ -108481,7 +108570,7 @@ function transformNodeModule(context) {
|
|
|
108481
108570
|
if (!currentSourceFile) {
|
|
108482
108571
|
return previousOnSubstituteNode(hint, node);
|
|
108483
108572
|
}
|
|
108484
|
-
if (currentSourceFile
|
|
108573
|
+
if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
|
|
108485
108574
|
return esmOnSubstituteNode(hint, node);
|
|
108486
108575
|
}
|
|
108487
108576
|
return cjsOnSubstituteNode(hint, node);
|
|
@@ -108494,13 +108583,13 @@ function transformNodeModule(context) {
|
|
|
108494
108583
|
if (!currentSourceFile) {
|
|
108495
108584
|
return previousOnEmitNode(hint, node, emitCallback);
|
|
108496
108585
|
}
|
|
108497
|
-
if (currentSourceFile
|
|
108586
|
+
if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
|
|
108498
108587
|
return esmOnEmitNode(hint, node, emitCallback);
|
|
108499
108588
|
}
|
|
108500
108589
|
return cjsOnEmitNode(hint, node, emitCallback);
|
|
108501
108590
|
}
|
|
108502
108591
|
function getModuleTransformForFile(file) {
|
|
108503
|
-
return file
|
|
108592
|
+
return getEmitModuleFormatOfFile(file) >= 5 /* ES2015 */ ? esmTransform : cjsTransform;
|
|
108504
108593
|
}
|
|
108505
108594
|
function transformSourceFile(node) {
|
|
108506
108595
|
if (node.isDeclarationFile) {
|
|
@@ -110403,17 +110492,18 @@ function isProcessedComponent(node) {
|
|
|
110403
110492
|
// src/compiler/transformer.ts
|
|
110404
110493
|
function getModuleTransformer(moduleKind) {
|
|
110405
110494
|
switch (moduleKind) {
|
|
110495
|
+
case 200 /* Preserve */:
|
|
110496
|
+
return transformECMAScriptModule;
|
|
110406
110497
|
case 99 /* ESNext */:
|
|
110407
110498
|
case 7 /* ES2022 */:
|
|
110408
110499
|
case 6 /* ES2020 */:
|
|
110409
110500
|
case 5 /* ES2015 */:
|
|
110410
|
-
case 200 /* Preserve */:
|
|
110411
|
-
return transformECMAScriptModule;
|
|
110412
|
-
case 4 /* System */:
|
|
110413
|
-
return transformSystemModule;
|
|
110414
110501
|
case 100 /* Node16 */:
|
|
110415
110502
|
case 199 /* NodeNext */:
|
|
110416
|
-
|
|
110503
|
+
case 1 /* CommonJS */:
|
|
110504
|
+
return transformImpliedNodeFormatDependentModule;
|
|
110505
|
+
case 4 /* System */:
|
|
110506
|
+
return transformSystemModule;
|
|
110417
110507
|
default:
|
|
110418
110508
|
return transformModule;
|
|
110419
110509
|
}
|
|
@@ -111137,6 +111227,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
111137
111227
|
newLine: compilerOptions.newLine,
|
|
111138
111228
|
noEmitHelpers: compilerOptions.noEmitHelpers,
|
|
111139
111229
|
module: getEmitModuleKind(compilerOptions),
|
|
111230
|
+
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
|
111140
111231
|
target: getEmitScriptTarget(compilerOptions),
|
|
111141
111232
|
sourceMap: compilerOptions.sourceMap,
|
|
111142
111233
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -111199,6 +111290,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
111199
111290
|
newLine: compilerOptions.newLine,
|
|
111200
111291
|
noEmitHelpers: true,
|
|
111201
111292
|
module: compilerOptions.module,
|
|
111293
|
+
moduleResolution: compilerOptions.moduleResolution,
|
|
111202
111294
|
target: compilerOptions.target,
|
|
111203
111295
|
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
|
111204
111296
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -116708,9 +116800,6 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
|
|
|
116708
116800
|
function getModeForFileReference(ref, containingFileMode) {
|
|
116709
116801
|
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
116710
116802
|
}
|
|
116711
|
-
function getModeForResolutionAtIndex(file, index, compilerOptions) {
|
|
116712
|
-
return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
|
|
116713
|
-
}
|
|
116714
116803
|
function isExclusivelyTypeOnlyImportOrExport(decl) {
|
|
116715
116804
|
var _a;
|
|
116716
116805
|
if (isExportDeclaration(decl)) {
|
|
@@ -116725,7 +116814,6 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
|
|
|
116725
116814
|
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
|
116726
116815
|
}
|
|
116727
116816
|
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
116728
|
-
var _a;
|
|
116729
116817
|
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
|
116730
116818
|
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
|
116731
116819
|
if (isTypeOnly) {
|
|
@@ -116741,20 +116829,28 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
|
116741
116829
|
return override;
|
|
116742
116830
|
}
|
|
116743
116831
|
}
|
|
116744
|
-
if (compilerOptions &&
|
|
116745
|
-
return usage
|
|
116746
|
-
usage.parent,
|
|
116747
|
-
/*requireStringLiteralLikeArgument*/
|
|
116748
|
-
false
|
|
116749
|
-
) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
116832
|
+
if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
|
|
116833
|
+
return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
|
|
116750
116834
|
}
|
|
116751
|
-
|
|
116835
|
+
}
|
|
116836
|
+
function getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions) {
|
|
116837
|
+
var _a;
|
|
116838
|
+
if (!compilerOptions) {
|
|
116752
116839
|
return void 0;
|
|
116753
|
-
if (file.impliedNodeFormat !== 99 /* ESNext */) {
|
|
116754
|
-
return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
116755
116840
|
}
|
|
116756
116841
|
const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
|
|
116757
|
-
|
|
116842
|
+
if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(
|
|
116843
|
+
usage.parent,
|
|
116844
|
+
/*requireStringLiteralLikeArgument*/
|
|
116845
|
+
false
|
|
116846
|
+
)) {
|
|
116847
|
+
return 1 /* CommonJS */;
|
|
116848
|
+
}
|
|
116849
|
+
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
|
116850
|
+
return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
116851
|
+
}
|
|
116852
|
+
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
|
116853
|
+
return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
|
|
116758
116854
|
}
|
|
116759
116855
|
function getResolutionModeOverride(node, grammarErrorOnNode) {
|
|
116760
116856
|
if (!node)
|
|
@@ -116814,7 +116910,7 @@ function getTypeReferenceResolutionName(entry) {
|
|
|
116814
116910
|
}
|
|
116815
116911
|
var typeReferenceResolutionNameAndModeGetter = {
|
|
116816
116912
|
getName: getTypeReferenceResolutionName,
|
|
116817
|
-
getMode: (entry, file) => getModeForFileReference(entry, file
|
|
116913
|
+
getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions))
|
|
116818
116914
|
};
|
|
116819
116915
|
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
116820
116916
|
return {
|
|
@@ -116998,13 +117094,7 @@ function getConfigFileParsingDiagnostics(configFileParseResult) {
|
|
|
116998
117094
|
return configFileParseResult.options.configFile ? [...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] : configFileParseResult.errors;
|
|
116999
117095
|
}
|
|
117000
117096
|
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
117001
|
-
|
|
117002
|
-
case 3 /* Node16 */:
|
|
117003
|
-
case 99 /* NodeNext */:
|
|
117004
|
-
return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
|
|
117005
|
-
default:
|
|
117006
|
-
return void 0;
|
|
117007
|
-
}
|
|
117097
|
+
return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
|
|
117008
117098
|
function lookupFromPackageJson() {
|
|
117009
117099
|
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
117010
117100
|
const packageJsonLocations = [];
|
|
@@ -117454,7 +117544,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
117454
117544
|
isSourceFileFromExternalLibrary,
|
|
117455
117545
|
isSourceFileDefaultLibrary,
|
|
117456
117546
|
getModeForUsageLocation: getModeForUsageLocation2,
|
|
117457
|
-
|
|
117547
|
+
getEmitSyntaxForUsageLocation,
|
|
117548
|
+
getModeForResolutionAtIndex,
|
|
117458
117549
|
getSourceFileFromReference,
|
|
117459
117550
|
getLibFileFromReference,
|
|
117460
117551
|
sourceFileToPackageName,
|
|
@@ -117481,6 +117572,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
117481
117572
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
117482
117573
|
isSourceOfProjectReferenceRedirect,
|
|
117483
117574
|
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
117575
|
+
getCompilerOptionsForFile,
|
|
117576
|
+
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
117577
|
+
getEmitModuleFormatOfFile,
|
|
117578
|
+
getImpliedNodeFormatForEmit,
|
|
117579
|
+
shouldTransformImportCall,
|
|
117484
117580
|
emitBuildInfo,
|
|
117485
117581
|
fileExists,
|
|
117486
117582
|
readFile,
|
|
@@ -118044,6 +118140,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118044
118140
|
getSymlinkCache,
|
|
118045
118141
|
writeFile: writeFileCallback || writeFile2,
|
|
118046
118142
|
isEmitBlocked,
|
|
118143
|
+
shouldTransformImportCall,
|
|
118144
|
+
getEmitModuleFormatOfFile,
|
|
118145
|
+
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
118146
|
+
getModeForResolutionAtIndex,
|
|
118047
118147
|
readFile: (f) => host.readFile(f),
|
|
118048
118148
|
fileExists: (f) => {
|
|
118049
118149
|
const path = toPath3(f);
|
|
@@ -119079,10 +119179,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119079
119179
|
const resolvedTypeReferenceDirective = resolutions[index];
|
|
119080
119180
|
const fileName = toFileNameLowerCase(ref.fileName);
|
|
119081
119181
|
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
|
119082
|
-
const mode = ref.resolutionMode || file
|
|
119182
|
+
const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
|
|
119083
119183
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
|
119084
119184
|
}
|
|
119085
119185
|
}
|
|
119186
|
+
function getCompilerOptionsForFile(file) {
|
|
119187
|
+
var _a2;
|
|
119188
|
+
return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
119189
|
+
}
|
|
119086
119190
|
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
119087
119191
|
var _a2, _b2;
|
|
119088
119192
|
(_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
|
|
@@ -119230,13 +119334,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119230
119334
|
return host.getCanonicalFileName(fileName);
|
|
119231
119335
|
}
|
|
119232
119336
|
function processImportedModules(file) {
|
|
119233
|
-
var _a2;
|
|
119234
119337
|
collectExternalModuleReferences(file);
|
|
119235
119338
|
if (file.imports.length || file.moduleAugmentations.length) {
|
|
119236
119339
|
const moduleNames = getModuleNames(file);
|
|
119237
119340
|
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
119238
119341
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
119239
|
-
const optionsForFile = (
|
|
119342
|
+
const optionsForFile = getCompilerOptionsForFile(file);
|
|
119240
119343
|
const resolutionsInFile = createModeAwareCache();
|
|
119241
119344
|
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
119242
119345
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
@@ -119772,7 +119875,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119772
119875
|
fileIncludeReasons = void 0;
|
|
119773
119876
|
const location = locationReason && getReferencedFileLocation(program, locationReason);
|
|
119774
119877
|
const fileIncludeReasonDetails = fileIncludeReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
119775
|
-
const
|
|
119878
|
+
const optionsForFile = file && getCompilerOptionsForFile(file) || options;
|
|
119879
|
+
const redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, optionsForFile);
|
|
119776
119880
|
const chain = chainDiagnosticMessages(redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails, diagnostic, ...args || emptyArray);
|
|
119777
119881
|
return location && isReferenceFileLocation(location) ? createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
|
|
119778
119882
|
function processReason(reason) {
|
|
@@ -120073,13 +120177,53 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120073
120177
|
return symlinks;
|
|
120074
120178
|
}
|
|
120075
120179
|
function getModeForUsageLocation2(file, usage) {
|
|
120076
|
-
|
|
120077
|
-
|
|
120078
|
-
|
|
120180
|
+
return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
|
120181
|
+
}
|
|
120182
|
+
function getEmitSyntaxForUsageLocation(file, usage) {
|
|
120183
|
+
return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
|
120079
120184
|
}
|
|
120080
|
-
function
|
|
120185
|
+
function getModeForResolutionAtIndex(file, index) {
|
|
120081
120186
|
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
|
120082
120187
|
}
|
|
120188
|
+
function getDefaultResolutionModeForFile2(sourceFile) {
|
|
120189
|
+
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
120190
|
+
}
|
|
120191
|
+
function getImpliedNodeFormatForEmit(sourceFile) {
|
|
120192
|
+
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
120193
|
+
}
|
|
120194
|
+
function getEmitModuleFormatOfFile(sourceFile) {
|
|
120195
|
+
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
120196
|
+
}
|
|
120197
|
+
function shouldTransformImportCall(sourceFile) {
|
|
120198
|
+
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
120199
|
+
}
|
|
120200
|
+
}
|
|
120201
|
+
function shouldTransformImportCallWorker(sourceFile, options) {
|
|
120202
|
+
const moduleKind = getEmitModuleKind(options);
|
|
120203
|
+
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
|
|
120204
|
+
return false;
|
|
120205
|
+
}
|
|
120206
|
+
return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
|
|
120207
|
+
}
|
|
120208
|
+
function getEmitModuleFormatOfFileWorker(sourceFile, options) {
|
|
120209
|
+
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
|
120210
|
+
}
|
|
120211
|
+
function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
|
|
120212
|
+
var _a, _b;
|
|
120213
|
+
const moduleKind = getEmitModuleKind(options);
|
|
120214
|
+
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
120215
|
+
return sourceFile.impliedNodeFormat;
|
|
120216
|
+
}
|
|
120217
|
+
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
|
|
120218
|
+
return 1 /* CommonJS */;
|
|
120219
|
+
}
|
|
120220
|
+
if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
|
|
120221
|
+
return 99 /* ESNext */;
|
|
120222
|
+
}
|
|
120223
|
+
return void 0;
|
|
120224
|
+
}
|
|
120225
|
+
function getDefaultResolutionModeForFileWorker(sourceFile, options) {
|
|
120226
|
+
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
|
|
120083
120227
|
}
|
|
120084
120228
|
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
|
120085
120229
|
let setOfDeclarationDirectories;
|
|
@@ -122052,9 +122196,15 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
|
|
|
122052
122196
|
const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
|
|
122053
122197
|
if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1)
|
|
122054
122198
|
return void 0;
|
|
122199
|
+
const lastNodeModulesIndex = failedLookupPathComponents.lastIndexOf("node_modules");
|
|
122055
122200
|
if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
|
|
122056
122201
|
if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
|
|
122057
|
-
return getDirectoryOfFailedLookupWatch(
|
|
122202
|
+
return getDirectoryOfFailedLookupWatch(
|
|
122203
|
+
failedLookupComponents,
|
|
122204
|
+
failedLookupPathComponents,
|
|
122205
|
+
Math.max(rootPathComponents.length + 1, perceivedOsRootLength + 1),
|
|
122206
|
+
lastNodeModulesIndex
|
|
122207
|
+
);
|
|
122058
122208
|
} else {
|
|
122059
122209
|
return {
|
|
122060
122210
|
dir: rootDir,
|
|
@@ -122069,12 +122219,18 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
|
|
|
122069
122219
|
failedLookupPathComponents.length - 1,
|
|
122070
122220
|
perceivedOsRootLength,
|
|
122071
122221
|
nodeModulesIndex,
|
|
122072
|
-
rootPathComponents
|
|
122222
|
+
rootPathComponents,
|
|
122223
|
+
lastNodeModulesIndex
|
|
122073
122224
|
);
|
|
122074
122225
|
}
|
|
122075
|
-
function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents) {
|
|
122226
|
+
function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents, lastNodeModulesIndex) {
|
|
122076
122227
|
if (nodeModulesIndex !== -1) {
|
|
122077
|
-
return getDirectoryOfFailedLookupWatch(
|
|
122228
|
+
return getDirectoryOfFailedLookupWatch(
|
|
122229
|
+
dirComponents,
|
|
122230
|
+
dirPathComponents,
|
|
122231
|
+
nodeModulesIndex + 1,
|
|
122232
|
+
lastNodeModulesIndex
|
|
122233
|
+
);
|
|
122078
122234
|
}
|
|
122079
122235
|
let nonRecursive = true;
|
|
122080
122236
|
let length2 = dirPathComponentsLength;
|
|
@@ -122085,13 +122241,29 @@ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dir
|
|
|
122085
122241
|
break;
|
|
122086
122242
|
}
|
|
122087
122243
|
}
|
|
122088
|
-
return getDirectoryOfFailedLookupWatch(
|
|
122244
|
+
return getDirectoryOfFailedLookupWatch(
|
|
122245
|
+
dirComponents,
|
|
122246
|
+
dirPathComponents,
|
|
122247
|
+
length2,
|
|
122248
|
+
lastNodeModulesIndex,
|
|
122249
|
+
nonRecursive
|
|
122250
|
+
);
|
|
122089
122251
|
}
|
|
122090
|
-
function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive) {
|
|
122252
|
+
function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, lastNodeModulesIndex, nonRecursive) {
|
|
122253
|
+
let packageDirLength;
|
|
122254
|
+
if (lastNodeModulesIndex !== -1 && lastNodeModulesIndex + 1 >= length2 && lastNodeModulesIndex + 2 < dirPathComponents.length) {
|
|
122255
|
+
if (!startsWith(dirPathComponents[lastNodeModulesIndex + 1], "@")) {
|
|
122256
|
+
packageDirLength = lastNodeModulesIndex + 2;
|
|
122257
|
+
} else if (lastNodeModulesIndex + 3 < dirPathComponents.length) {
|
|
122258
|
+
packageDirLength = lastNodeModulesIndex + 3;
|
|
122259
|
+
}
|
|
122260
|
+
}
|
|
122091
122261
|
return {
|
|
122092
122262
|
dir: getPathFromPathComponents(dirComponents, length2),
|
|
122093
122263
|
dirPath: getPathFromPathComponents(dirPathComponents, length2),
|
|
122094
|
-
nonRecursive
|
|
122264
|
+
nonRecursive,
|
|
122265
|
+
packageDir: packageDirLength !== void 0 ? getPathFromPathComponents(dirComponents, packageDirLength) : void 0,
|
|
122266
|
+
packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
|
|
122095
122267
|
};
|
|
122096
122268
|
}
|
|
122097
122269
|
function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, filterCustomPath) {
|
|
@@ -122106,7 +122278,8 @@ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootP
|
|
|
122106
122278
|
typeRootPathComponents.length,
|
|
122107
122279
|
perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
|
|
122108
122280
|
typeRootPathComponents.indexOf("node_modules"),
|
|
122109
|
-
rootPathComponents
|
|
122281
|
+
rootPathComponents,
|
|
122282
|
+
typeRootPathComponents.lastIndexOf("node_modules")
|
|
122110
122283
|
);
|
|
122111
122284
|
return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
122112
122285
|
}
|
|
@@ -122202,6 +122375,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122202
122375
|
const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
|
|
122203
122376
|
const rootPath = resolutionHost.toPath(rootDir);
|
|
122204
122377
|
const rootPathComponents = getPathComponents(rootPath);
|
|
122378
|
+
const isSymlinkCache = /* @__PURE__ */ new Map();
|
|
122379
|
+
const packageDirWatchers = /* @__PURE__ */ new Map();
|
|
122380
|
+
const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
|
|
122205
122381
|
const typeRootsWatches = /* @__PURE__ */ new Map();
|
|
122206
122382
|
return {
|
|
122207
122383
|
rootDirForResolution,
|
|
@@ -122213,6 +122389,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122213
122389
|
resolutionsWithOnlyAffectingLocations,
|
|
122214
122390
|
directoryWatchesOfFailedLookups,
|
|
122215
122391
|
fileWatchesOfAffectingLocations,
|
|
122392
|
+
packageDirWatchers,
|
|
122393
|
+
dirPathToSymlinkPackageRefCount,
|
|
122216
122394
|
watchFailedLookupLocationsOfExternalModuleResolutions,
|
|
122217
122395
|
getModuleResolutionCache: () => moduleResolutionCache,
|
|
122218
122396
|
startRecordingFilesWithChangedResolutions,
|
|
@@ -122247,6 +122425,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122247
122425
|
function clear2() {
|
|
122248
122426
|
clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
|
|
122249
122427
|
clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
|
|
122428
|
+
isSymlinkCache.clear();
|
|
122429
|
+
packageDirWatchers.clear();
|
|
122430
|
+
dirPathToSymlinkPackageRefCount.clear();
|
|
122250
122431
|
nonRelativeExternalModuleResolutions.clear();
|
|
122251
122432
|
closeTypeRootsWatch();
|
|
122252
122433
|
resolvedModuleNames.clear();
|
|
@@ -122313,6 +122494,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122313
122494
|
libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122314
122495
|
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122315
122496
|
nonRelativeExternalModuleResolutions.clear();
|
|
122497
|
+
isSymlinkCache.clear();
|
|
122316
122498
|
}
|
|
122317
122499
|
function cleanupLibResolutionWatching(newProgram) {
|
|
122318
122500
|
resolvedLibraries.forEach((resolution, libFileName) => {
|
|
@@ -122365,11 +122547,18 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122365
122547
|
}
|
|
122366
122548
|
directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup);
|
|
122367
122549
|
fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation);
|
|
122550
|
+
packageDirWatchers.forEach(closePackageDirWatcher);
|
|
122368
122551
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122369
122552
|
moduleResolutionCache.isReadonly = true;
|
|
122370
122553
|
typeReferenceDirectiveResolutionCache.isReadonly = true;
|
|
122371
122554
|
libraryResolutionCache.isReadonly = true;
|
|
122372
122555
|
moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true;
|
|
122556
|
+
isSymlinkCache.clear();
|
|
122557
|
+
}
|
|
122558
|
+
function closePackageDirWatcher(watcher, packageDirPath) {
|
|
122559
|
+
if (watcher.dirPathToWatcher.size === 0) {
|
|
122560
|
+
packageDirWatchers.delete(packageDirPath);
|
|
122561
|
+
}
|
|
122373
122562
|
}
|
|
122374
122563
|
function closeDirectoryWatchesOfFailedLookup(watcher, path) {
|
|
122375
122564
|
if (watcher.refCount === 0) {
|
|
@@ -122619,12 +122808,13 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122619
122808
|
getCurrentDirectory
|
|
122620
122809
|
);
|
|
122621
122810
|
if (toWatch) {
|
|
122622
|
-
const { dir, dirPath, nonRecursive } = toWatch;
|
|
122811
|
+
const { dir, dirPath, nonRecursive, packageDir, packageDirPath } = toWatch;
|
|
122623
122812
|
if (dirPath === rootPath) {
|
|
122624
122813
|
Debug.assert(nonRecursive);
|
|
122814
|
+
Debug.assert(!packageDir);
|
|
122625
122815
|
setAtRoot = true;
|
|
122626
122816
|
} else {
|
|
122627
|
-
setDirectoryWatcher(dir, dirPath, nonRecursive);
|
|
122817
|
+
setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive);
|
|
122628
122818
|
}
|
|
122629
122819
|
}
|
|
122630
122820
|
return setAtRoot;
|
|
@@ -122648,6 +122838,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122648
122838
|
setDirectoryWatcher(
|
|
122649
122839
|
rootDir,
|
|
122650
122840
|
rootPath,
|
|
122841
|
+
/*packageDir*/
|
|
122842
|
+
void 0,
|
|
122843
|
+
/*packageDirPath*/
|
|
122844
|
+
void 0,
|
|
122651
122845
|
/*nonRecursive*/
|
|
122652
122846
|
true
|
|
122653
122847
|
);
|
|
@@ -122748,14 +122942,68 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122748
122942
|
));
|
|
122749
122943
|
}
|
|
122750
122944
|
}
|
|
122751
|
-
function
|
|
122752
|
-
|
|
122945
|
+
function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
|
|
122946
|
+
Debug.assert(!nonRecursive);
|
|
122947
|
+
let isSymlink = isSymlinkCache.get(packageDirPath);
|
|
122948
|
+
let packageDirWatcher = packageDirWatchers.get(packageDirPath);
|
|
122949
|
+
if (isSymlink === void 0) {
|
|
122950
|
+
const realPath2 = resolutionHost.realpath(packageDir);
|
|
122951
|
+
isSymlink = realPath2 !== packageDir && resolutionHost.toPath(realPath2) !== packageDirPath;
|
|
122952
|
+
isSymlinkCache.set(packageDirPath, isSymlink);
|
|
122953
|
+
if (!packageDirWatcher) {
|
|
122954
|
+
packageDirWatchers.set(
|
|
122955
|
+
packageDirPath,
|
|
122956
|
+
packageDirWatcher = {
|
|
122957
|
+
dirPathToWatcher: /* @__PURE__ */ new Map(),
|
|
122958
|
+
isSymlink
|
|
122959
|
+
}
|
|
122960
|
+
);
|
|
122961
|
+
} else if (packageDirWatcher.isSymlink !== isSymlink) {
|
|
122962
|
+
packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
|
|
122963
|
+
removeDirectoryWatcher(
|
|
122964
|
+
packageDirWatcher.isSymlink ? packageDirPath : dirPath,
|
|
122965
|
+
/*syncDirWatcherRemove*/
|
|
122966
|
+
false
|
|
122967
|
+
);
|
|
122968
|
+
watcher.watcher = createDirPathToWatcher();
|
|
122969
|
+
});
|
|
122970
|
+
packageDirWatcher.isSymlink = isSymlink;
|
|
122971
|
+
}
|
|
122972
|
+
} else {
|
|
122973
|
+
Debug.assertIsDefined(packageDirWatcher);
|
|
122974
|
+
Debug.assert(isSymlink === packageDirWatcher.isSymlink);
|
|
122975
|
+
}
|
|
122976
|
+
const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
|
|
122977
|
+
if (forDirPath) {
|
|
122978
|
+
forDirPath.refCount++;
|
|
122979
|
+
} else {
|
|
122980
|
+
packageDirWatcher.dirPathToWatcher.set(dirPath, {
|
|
122981
|
+
watcher: createDirPathToWatcher(),
|
|
122982
|
+
refCount: 1
|
|
122983
|
+
});
|
|
122984
|
+
if (isSymlink)
|
|
122985
|
+
dirPathToSymlinkPackageRefCount.set(dirPath, (dirPathToSymlinkPackageRefCount.get(dirPath) ?? 0) + 1);
|
|
122986
|
+
}
|
|
122987
|
+
function createDirPathToWatcher() {
|
|
122988
|
+
return isSymlink ? createOrAddRefToDirectoryWatchOfFailedLookups(packageDir, packageDirPath, nonRecursive) : createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
|
|
122989
|
+
}
|
|
122990
|
+
}
|
|
122991
|
+
function setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
|
|
122992
|
+
if (!packageDirPath || !resolutionHost.realpath) {
|
|
122993
|
+
createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
|
|
122994
|
+
} else {
|
|
122995
|
+
createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive);
|
|
122996
|
+
}
|
|
122997
|
+
}
|
|
122998
|
+
function createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive) {
|
|
122999
|
+
let dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
|
|
122753
123000
|
if (dirWatcher) {
|
|
122754
123001
|
Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
|
|
122755
123002
|
dirWatcher.refCount++;
|
|
122756
123003
|
} else {
|
|
122757
|
-
directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive });
|
|
123004
|
+
directoryWatchesOfFailedLookups.set(dirPath, dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive });
|
|
122758
123005
|
}
|
|
123006
|
+
return dirWatcher;
|
|
122759
123007
|
}
|
|
122760
123008
|
function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove) {
|
|
122761
123009
|
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
@@ -122768,9 +123016,27 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122768
123016
|
getCurrentDirectory
|
|
122769
123017
|
);
|
|
122770
123018
|
if (toWatch) {
|
|
122771
|
-
const { dirPath } = toWatch;
|
|
123019
|
+
const { dirPath, packageDirPath } = toWatch;
|
|
122772
123020
|
if (dirPath === rootPath) {
|
|
122773
123021
|
removeAtRoot = true;
|
|
123022
|
+
} else if (packageDirPath && resolutionHost.realpath) {
|
|
123023
|
+
const packageDirWatcher = packageDirWatchers.get(packageDirPath);
|
|
123024
|
+
const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
|
|
123025
|
+
forDirPath.refCount--;
|
|
123026
|
+
if (forDirPath.refCount === 0) {
|
|
123027
|
+
removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath, syncDirWatcherRemove);
|
|
123028
|
+
packageDirWatcher.dirPathToWatcher.delete(dirPath);
|
|
123029
|
+
if (packageDirWatcher.isSymlink) {
|
|
123030
|
+
const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
|
|
123031
|
+
if (refCount === 0) {
|
|
123032
|
+
dirPathToSymlinkPackageRefCount.delete(dirPath);
|
|
123033
|
+
} else {
|
|
123034
|
+
dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
|
|
123035
|
+
}
|
|
123036
|
+
}
|
|
123037
|
+
if (syncDirWatcherRemove)
|
|
123038
|
+
closePackageDirWatcher(packageDirWatcher, packageDirPath);
|
|
123039
|
+
}
|
|
122774
123040
|
} else {
|
|
122775
123041
|
removeDirectoryWatcher(dirPath, syncDirWatcherRemove);
|
|
122776
123042
|
}
|
|
@@ -122992,7 +123258,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
122992
123258
|
rootPath,
|
|
122993
123259
|
rootPathComponents,
|
|
122994
123260
|
getCurrentDirectory,
|
|
122995
|
-
(dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
|
|
123261
|
+
(dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
|
|
122996
123262
|
);
|
|
122997
123263
|
if (dirPath) {
|
|
122998
123264
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
@@ -123198,10 +123464,10 @@ function explainFiles(program, write) {
|
|
|
123198
123464
|
for (const file of program.getSourceFiles()) {
|
|
123199
123465
|
write(`${toFileName(file, relativeFileName)}`);
|
|
123200
123466
|
(_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
|
123201
|
-
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
|
123467
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
|
123202
123468
|
}
|
|
123203
123469
|
}
|
|
123204
|
-
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
123470
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConvertor) {
|
|
123205
123471
|
var _a;
|
|
123206
123472
|
let result;
|
|
123207
123473
|
if (file.path !== file.resolvedPath) {
|
|
@@ -123221,7 +123487,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
|
123221
123487
|
));
|
|
123222
123488
|
}
|
|
123223
123489
|
if (isExternalOrCommonJsModule(file)) {
|
|
123224
|
-
switch (file
|
|
123490
|
+
switch (getImpliedNodeFormatForEmitWorker(file, options)) {
|
|
123225
123491
|
case 99 /* ESNext */:
|
|
123226
123492
|
if (file.packageJsonScope) {
|
|
123227
123493
|
(result ?? (result = [])).push(chainDiagnosticMessages(
|