typescript 5.5.0-dev.20240603 → 5.5.2
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 +204 -252
- package/lib/typescript.d.ts +22 -89
- package/lib/typescript.js +284 -371
- 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 =
|
|
21
|
+
var version = "5.5.2";
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -5923,7 +5923,6 @@ var Diagnostics = {
|
|
|
5923
5923
|
_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 }'."),
|
|
5924
5924
|
_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."),
|
|
5925
5925
|
_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 }'."),
|
|
5926
|
-
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'."),
|
|
5927
5926
|
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."),
|
|
5928
5927
|
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."),
|
|
5929
5928
|
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."),
|
|
@@ -12459,6 +12458,9 @@ function createSymbolTable(symbols) {
|
|
|
12459
12458
|
function isTransientSymbol(symbol) {
|
|
12460
12459
|
return (symbol.flags & 33554432 /* Transient */) !== 0;
|
|
12461
12460
|
}
|
|
12461
|
+
function isExternalModuleSymbol(moduleSymbol) {
|
|
12462
|
+
return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.escapedName.charCodeAt(0) === 34 /* doubleQuote */;
|
|
12463
|
+
}
|
|
12462
12464
|
var stringWriter = createSingleLineStringWriter();
|
|
12463
12465
|
function createSingleLineStringWriter() {
|
|
12464
12466
|
var str = "";
|
|
@@ -14736,23 +14738,6 @@ function isFunctionSymbol(symbol) {
|
|
|
14736
14738
|
const decl = symbol.valueDeclaration;
|
|
14737
14739
|
return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
|
|
14738
14740
|
}
|
|
14739
|
-
function canHaveModuleSpecifier(node) {
|
|
14740
|
-
switch (node == null ? void 0 : node.kind) {
|
|
14741
|
-
case 260 /* VariableDeclaration */:
|
|
14742
|
-
case 208 /* BindingElement */:
|
|
14743
|
-
case 272 /* ImportDeclaration */:
|
|
14744
|
-
case 278 /* ExportDeclaration */:
|
|
14745
|
-
case 271 /* ImportEqualsDeclaration */:
|
|
14746
|
-
case 273 /* ImportClause */:
|
|
14747
|
-
case 280 /* NamespaceExport */:
|
|
14748
|
-
case 274 /* NamespaceImport */:
|
|
14749
|
-
case 281 /* ExportSpecifier */:
|
|
14750
|
-
case 276 /* ImportSpecifier */:
|
|
14751
|
-
case 205 /* ImportType */:
|
|
14752
|
-
return true;
|
|
14753
|
-
}
|
|
14754
|
-
return false;
|
|
14755
|
-
}
|
|
14756
14741
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
14757
14742
|
var _a, _b;
|
|
14758
14743
|
switch (node.kind) {
|
|
@@ -17470,8 +17455,8 @@ function walkTreeForJSXTags(node) {
|
|
|
17470
17455
|
function isFileModuleFromUsingJSXTag(file) {
|
|
17471
17456
|
return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
|
|
17472
17457
|
}
|
|
17473
|
-
function isFileForcedToBeModuleByFormat(file
|
|
17474
|
-
return (
|
|
17458
|
+
function isFileForcedToBeModuleByFormat(file) {
|
|
17459
|
+
return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
|
|
17475
17460
|
}
|
|
17476
17461
|
function getSetExternalModuleIndicator(options) {
|
|
17477
17462
|
switch (getEmitModuleDetectionKind(options)) {
|
|
@@ -17490,14 +17475,10 @@ function getSetExternalModuleIndicator(options) {
|
|
|
17490
17475
|
}
|
|
17491
17476
|
checks.push(isFileForcedToBeModuleByFormat);
|
|
17492
17477
|
const combined = or(...checks);
|
|
17493
|
-
const callback = (file) => void (file.externalModuleIndicator = combined(file
|
|
17478
|
+
const callback = (file) => void (file.externalModuleIndicator = combined(file));
|
|
17494
17479
|
return callback;
|
|
17495
17480
|
}
|
|
17496
17481
|
}
|
|
17497
|
-
function importSyntaxAffectsModuleResolution(options) {
|
|
17498
|
-
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
17499
|
-
return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
|
|
17500
|
-
}
|
|
17501
17482
|
function createComputedCompilerOptions(options) {
|
|
17502
17483
|
return options;
|
|
17503
17484
|
}
|
|
@@ -19171,7 +19152,7 @@ function createNameResolver({
|
|
|
19171
19152
|
}
|
|
19172
19153
|
break;
|
|
19173
19154
|
}
|
|
19174
|
-
if (isSelfReferenceLocation(location)) {
|
|
19155
|
+
if (isSelfReferenceLocation(location, lastLocation)) {
|
|
19175
19156
|
lastSelfReferenceLocation = location;
|
|
19176
19157
|
}
|
|
19177
19158
|
lastLocation = location;
|
|
@@ -19272,8 +19253,10 @@ function createNameResolver({
|
|
|
19272
19253
|
}
|
|
19273
19254
|
return !getImmediatelyInvokedFunctionExpression(location);
|
|
19274
19255
|
}
|
|
19275
|
-
function isSelfReferenceLocation(node) {
|
|
19256
|
+
function isSelfReferenceLocation(node, lastLocation) {
|
|
19276
19257
|
switch (node.kind) {
|
|
19258
|
+
case 169 /* Parameter */:
|
|
19259
|
+
return !!lastLocation && lastLocation === node.name;
|
|
19277
19260
|
case 262 /* FunctionDeclaration */:
|
|
19278
19261
|
case 263 /* ClassDeclaration */:
|
|
19279
19262
|
case 264 /* InterfaceDeclaration */:
|
|
@@ -26655,7 +26638,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
|
|
|
26655
26638
|
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
26656
26639
|
let namedBindings;
|
|
26657
26640
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
26658
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ ||
|
|
26641
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
26659
26642
|
const helpers = getEmitHelpers(sourceFile);
|
|
26660
26643
|
if (helpers) {
|
|
26661
26644
|
const helperNames = [];
|
|
@@ -26720,7 +26703,8 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
|
|
|
26720
26703
|
if (externalHelpersModuleName) {
|
|
26721
26704
|
return externalHelpersModuleName;
|
|
26722
26705
|
}
|
|
26723
|
-
|
|
26706
|
+
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
26707
|
+
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
|
|
26724
26708
|
if (!create) {
|
|
26725
26709
|
const helpers = getEmitHelpers(node);
|
|
26726
26710
|
if (helpers) {
|
|
@@ -44129,15 +44113,13 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
|
|
|
44129
44113
|
}
|
|
44130
44114
|
|
|
44131
44115
|
// src/compiler/moduleSpecifiers.ts
|
|
44132
|
-
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding },
|
|
44116
|
+
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
|
44133
44117
|
const filePreferredEnding = getPreferredEnding();
|
|
44134
44118
|
return {
|
|
44135
44119
|
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 */,
|
|
44136
44120
|
getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
|
|
44137
|
-
const
|
|
44138
|
-
|
|
44139
|
-
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
44140
|
-
if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
|
|
44121
|
+
const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
|
44122
|
+
if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
|
|
44141
44123
|
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
|
44142
44124
|
return [3 /* TsExtension */, 2 /* JsExtension */];
|
|
44143
44125
|
}
|
|
@@ -44168,7 +44150,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
|
|
|
44168
44150
|
}
|
|
44169
44151
|
return getModuleSpecifierEndingPreference(
|
|
44170
44152
|
importModuleSpecifierEnding,
|
|
44171
|
-
resolutionMode ??
|
|
44153
|
+
resolutionMode ?? importingSourceFile.impliedNodeFormat,
|
|
44172
44154
|
compilerOptions,
|
|
44173
44155
|
isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
|
|
44174
44156
|
);
|
|
@@ -44226,16 +44208,12 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
|
|
44226
44208
|
}
|
|
44227
44209
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
44228
44210
|
const info = getInfo(importingSourceFile.fileName, host);
|
|
44229
|
-
const preferences = getModuleSpecifierPreferences(userPreferences,
|
|
44211
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
44230
44212
|
const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
|
|
44231
44213
|
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
|
44232
44214
|
(reason) => {
|
|
44233
44215
|
if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
|
|
44234
|
-
|
|
44235
|
-
const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
|
|
44236
|
-
if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
|
|
44237
|
-
return void 0;
|
|
44238
|
-
}
|
|
44216
|
+
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
|
|
44239
44217
|
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
|
44240
44218
|
return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
|
|
44241
44219
|
}
|
|
@@ -44750,7 +44728,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
44750
44728
|
if (!parts) {
|
|
44751
44729
|
return void 0;
|
|
44752
44730
|
}
|
|
44753
|
-
const preferences = getModuleSpecifierPreferences(userPreferences,
|
|
44731
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
|
|
44754
44732
|
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
|
44755
44733
|
let moduleSpecifier = path;
|
|
44756
44734
|
let isPackageRootPath = false;
|
|
@@ -44800,7 +44778,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
44800
44778
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
44801
44779
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
|
44802
44780
|
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
44803
|
-
const importMode = overrideMode ||
|
|
44781
|
+
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
44804
44782
|
if (getResolvePackageJsonExports(options)) {
|
|
44805
44783
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
|
44806
44784
|
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
|
@@ -44950,9 +44928,6 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
|
|
|
44950
44928
|
function isPathRelativeToParent(path) {
|
|
44951
44929
|
return startsWith(path, "..");
|
|
44952
44930
|
}
|
|
44953
|
-
function getDefaultResolutionModeForFile(file, host, compilerOptions) {
|
|
44954
|
-
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
|
44955
|
-
}
|
|
44956
44931
|
|
|
44957
44932
|
// src/compiler/checker.ts
|
|
44958
44933
|
var ambientModuleSymbolRegex = /^".+"$/;
|
|
@@ -47159,28 +47134,22 @@ function createTypeChecker(host) {
|
|
|
47159
47134
|
function isSyntacticDefault(node) {
|
|
47160
47135
|
return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
|
|
47161
47136
|
}
|
|
47162
|
-
function
|
|
47163
|
-
return isStringLiteralLike(usage) ? host.
|
|
47137
|
+
function getUsageModeForExpression(usage) {
|
|
47138
|
+
return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
|
47164
47139
|
}
|
|
47165
47140
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
47166
47141
|
return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
|
|
47167
47142
|
}
|
|
47168
|
-
function
|
|
47169
|
-
|
|
47170
|
-
|
|
47171
|
-
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
|
47172
|
-
}
|
|
47173
|
-
return false;
|
|
47143
|
+
function isOnlyImportedAsDefault(usage) {
|
|
47144
|
+
const usageMode = getUsageModeForExpression(usage);
|
|
47145
|
+
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
|
47174
47146
|
}
|
|
47175
47147
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
47176
|
-
const usageMode = file &&
|
|
47177
|
-
if (file && usageMode !== void 0) {
|
|
47178
|
-
const
|
|
47179
|
-
if (usageMode === 99 /* ESNext */
|
|
47180
|
-
return
|
|
47181
|
-
}
|
|
47182
|
-
if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
|
|
47183
|
-
return false;
|
|
47148
|
+
const usageMode = file && getUsageModeForExpression(usage);
|
|
47149
|
+
if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
47150
|
+
const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
47151
|
+
if (usageMode === 99 /* ESNext */ || result) {
|
|
47152
|
+
return result;
|
|
47184
47153
|
}
|
|
47185
47154
|
}
|
|
47186
47155
|
if (!allowSyntheticDefaultImports) {
|
|
@@ -47239,7 +47208,7 @@ function createTypeChecker(host) {
|
|
|
47239
47208
|
if (!specifier) {
|
|
47240
47209
|
return exportDefaultSymbol;
|
|
47241
47210
|
}
|
|
47242
|
-
const hasDefaultOnly =
|
|
47211
|
+
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
|
|
47243
47212
|
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
|
47244
47213
|
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
47245
47214
|
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
|
|
@@ -47440,7 +47409,7 @@ function createTypeChecker(host) {
|
|
|
47440
47409
|
let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
47441
47410
|
if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
|
|
47442
47411
|
const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
47443
|
-
if (
|
|
47412
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
47444
47413
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
47445
47414
|
}
|
|
47446
47415
|
}
|
|
@@ -48040,7 +48009,7 @@ function createTypeChecker(host) {
|
|
|
48040
48009
|
/*requireStringLiteralLikeArgument*/
|
|
48041
48010
|
true
|
|
48042
48011
|
) ? 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);
|
|
48043
|
-
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) :
|
|
48012
|
+
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
48044
48013
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
48045
48014
|
const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
|
|
48046
48015
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
@@ -48284,7 +48253,7 @@ function createTypeChecker(host) {
|
|
|
48284
48253
|
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
48285
48254
|
}
|
|
48286
48255
|
const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
48287
|
-
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(
|
|
48256
|
+
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
|
|
48288
48257
|
if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
|
|
48289
48258
|
let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
48290
48259
|
if (!sigs || !sigs.length) {
|
|
@@ -50890,10 +50859,8 @@ function createTypeChecker(host) {
|
|
|
50890
50859
|
}
|
|
50891
50860
|
return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
|
|
50892
50861
|
}
|
|
50893
|
-
const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
|
|
50894
|
-
const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
|
|
50895
50862
|
const contextFile = context.enclosingFile;
|
|
50896
|
-
const resolutionMode = overrideImportMode ||
|
|
50863
|
+
const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
|
|
50897
50864
|
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
|
50898
50865
|
const links = getSymbolLinks(symbol);
|
|
50899
50866
|
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
|
@@ -51544,10 +51511,11 @@ function createTypeChecker(host) {
|
|
|
51544
51511
|
return result ? setTextRange2(context, result, node) : void 0;
|
|
51545
51512
|
}
|
|
51546
51513
|
function createRecoveryBoundary() {
|
|
51514
|
+
let trackedSymbols;
|
|
51547
51515
|
let unreportedErrors;
|
|
51548
51516
|
const oldTracker = context.tracker;
|
|
51549
51517
|
const oldTrackedSymbols = context.trackedSymbols;
|
|
51550
|
-
context.trackedSymbols =
|
|
51518
|
+
context.trackedSymbols = void 0;
|
|
51551
51519
|
const oldEncounteredError = context.encounteredError;
|
|
51552
51520
|
context.tracker = new SymbolTrackerImpl(context, {
|
|
51553
51521
|
...oldTracker.inner,
|
|
@@ -51567,17 +51535,7 @@ function createTypeChecker(host) {
|
|
|
51567
51535
|
markError(() => oldTracker.reportNonSerializableProperty(name));
|
|
51568
51536
|
},
|
|
51569
51537
|
trackSymbol(sym, decl, meaning) {
|
|
51570
|
-
|
|
51571
|
-
sym,
|
|
51572
|
-
decl,
|
|
51573
|
-
meaning,
|
|
51574
|
-
/*shouldComputeAliasesToMakeVisible*/
|
|
51575
|
-
false
|
|
51576
|
-
);
|
|
51577
|
-
if (accessibility.accessibility !== 0 /* Accessible */) {
|
|
51578
|
-
(context.trackedSymbols ?? (context.trackedSymbols = [])).push([sym, decl, meaning]);
|
|
51579
|
-
return true;
|
|
51580
|
-
}
|
|
51538
|
+
(trackedSymbols ?? (trackedSymbols = [])).push([sym, decl, meaning]);
|
|
51581
51539
|
return false;
|
|
51582
51540
|
},
|
|
51583
51541
|
moduleResolverHost: context.tracker.moduleResolverHost
|
|
@@ -51591,13 +51549,12 @@ function createTypeChecker(host) {
|
|
|
51591
51549
|
(unreportedErrors ?? (unreportedErrors = [])).push(unreportedError);
|
|
51592
51550
|
}
|
|
51593
51551
|
function startRecoveryScope2() {
|
|
51594
|
-
|
|
51595
|
-
const initialTrackedSymbolsTop = ((_a = context.trackedSymbols) == null ? void 0 : _a.length) ?? 0;
|
|
51552
|
+
const trackedSymbolsTop = (trackedSymbols == null ? void 0 : trackedSymbols.length) ?? 0;
|
|
51596
51553
|
const unreportedErrorsTop = (unreportedErrors == null ? void 0 : unreportedErrors.length) ?? 0;
|
|
51597
51554
|
return () => {
|
|
51598
51555
|
hadError = false;
|
|
51599
|
-
if (
|
|
51600
|
-
|
|
51556
|
+
if (trackedSymbols) {
|
|
51557
|
+
trackedSymbols.length = trackedSymbolsTop;
|
|
51601
51558
|
}
|
|
51602
51559
|
if (unreportedErrors) {
|
|
51603
51560
|
unreportedErrors.length = unreportedErrorsTop;
|
|
@@ -51606,14 +51563,13 @@ function createTypeChecker(host) {
|
|
|
51606
51563
|
}
|
|
51607
51564
|
function finalizeBoundary2() {
|
|
51608
51565
|
context.tracker = oldTracker;
|
|
51609
|
-
const newTrackedSymbols = context.trackedSymbols;
|
|
51610
51566
|
context.trackedSymbols = oldTrackedSymbols;
|
|
51611
51567
|
context.encounteredError = oldEncounteredError;
|
|
51612
51568
|
unreportedErrors == null ? void 0 : unreportedErrors.forEach((fn) => fn());
|
|
51613
51569
|
if (hadError) {
|
|
51614
51570
|
return false;
|
|
51615
51571
|
}
|
|
51616
|
-
|
|
51572
|
+
trackedSymbols == null ? void 0 : trackedSymbols.forEach(
|
|
51617
51573
|
([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
|
|
51618
51574
|
symbol,
|
|
51619
51575
|
enclosingDeclaration,
|
|
@@ -51626,6 +51582,57 @@ function createTypeChecker(host) {
|
|
|
51626
51582
|
function onEnterNewScope(node) {
|
|
51627
51583
|
return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
|
|
51628
51584
|
}
|
|
51585
|
+
function tryVisitSimpleTypeNode(node) {
|
|
51586
|
+
const innerNode = skipTypeParentheses(node);
|
|
51587
|
+
switch (innerNode.kind) {
|
|
51588
|
+
case 183 /* TypeReference */:
|
|
51589
|
+
return tryVisitTypeReference(innerNode);
|
|
51590
|
+
case 186 /* TypeQuery */:
|
|
51591
|
+
return tryVisitTypeQuery(innerNode);
|
|
51592
|
+
case 199 /* IndexedAccessType */:
|
|
51593
|
+
return tryVisitIndexedAccess(innerNode);
|
|
51594
|
+
case 198 /* TypeOperator */:
|
|
51595
|
+
const typeOperatorNode = innerNode;
|
|
51596
|
+
if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
|
|
51597
|
+
return tryVisitKeyOf(typeOperatorNode);
|
|
51598
|
+
}
|
|
51599
|
+
}
|
|
51600
|
+
return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
|
|
51601
|
+
}
|
|
51602
|
+
function tryVisitIndexedAccess(node) {
|
|
51603
|
+
const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
|
|
51604
|
+
if (resultObjectType === void 0) {
|
|
51605
|
+
return void 0;
|
|
51606
|
+
}
|
|
51607
|
+
return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
|
|
51608
|
+
}
|
|
51609
|
+
function tryVisitKeyOf(node) {
|
|
51610
|
+
Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
|
|
51611
|
+
const type = tryVisitSimpleTypeNode(node.type);
|
|
51612
|
+
if (type === void 0) {
|
|
51613
|
+
return void 0;
|
|
51614
|
+
}
|
|
51615
|
+
return factory.updateTypeOperatorNode(node, type);
|
|
51616
|
+
}
|
|
51617
|
+
function tryVisitTypeQuery(node) {
|
|
51618
|
+
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
|
|
51619
|
+
if (!introducesError) {
|
|
51620
|
+
return factory.updateTypeQueryNode(
|
|
51621
|
+
node,
|
|
51622
|
+
exprName,
|
|
51623
|
+
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
51624
|
+
);
|
|
51625
|
+
}
|
|
51626
|
+
const serializedName = serializeTypeName(
|
|
51627
|
+
context,
|
|
51628
|
+
node.exprName,
|
|
51629
|
+
/*isTypeOf*/
|
|
51630
|
+
true
|
|
51631
|
+
);
|
|
51632
|
+
if (serializedName) {
|
|
51633
|
+
return setTextRange2(context, serializedName, node.exprName);
|
|
51634
|
+
}
|
|
51635
|
+
}
|
|
51629
51636
|
function tryVisitTypeReference(node) {
|
|
51630
51637
|
if (canReuseTypeNode(context, node)) {
|
|
51631
51638
|
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
|
|
@@ -51675,7 +51682,7 @@ function createTypeChecker(host) {
|
|
|
51675
51682
|
}
|
|
51676
51683
|
if (isJSDocTypeLiteral(node)) {
|
|
51677
51684
|
return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
|
|
51678
|
-
const name = isIdentifier(t.name) ? t.name : t.name.right;
|
|
51685
|
+
const name = visitNode(isIdentifier(t.name) ? t.name : t.name.right, visitExistingNodeTreeSymbols, isIdentifier);
|
|
51679
51686
|
const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
|
|
51680
51687
|
const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
|
|
51681
51688
|
return factory.createPropertySignature(
|
|
@@ -51719,7 +51726,7 @@ function createTypeChecker(host) {
|
|
|
51719
51726
|
void 0,
|
|
51720
51727
|
getEffectiveDotDotDotForParameter(p),
|
|
51721
51728
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
51722
|
-
p.questionToken,
|
|
51729
|
+
factory.cloneNode(p.questionToken),
|
|
51723
51730
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
51724
51731
|
/*initializer*/
|
|
51725
51732
|
void 0
|
|
@@ -51734,7 +51741,7 @@ function createTypeChecker(host) {
|
|
|
51734
51741
|
void 0,
|
|
51735
51742
|
getEffectiveDotDotDotForParameter(p),
|
|
51736
51743
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
51737
|
-
p.questionToken,
|
|
51744
|
+
factory.cloneNode(p.questionToken),
|
|
51738
51745
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
51739
51746
|
/*initializer*/
|
|
51740
51747
|
void 0
|
|
@@ -51753,19 +51760,19 @@ function createTypeChecker(host) {
|
|
|
51753
51760
|
if (isTypeParameterDeclaration(node)) {
|
|
51754
51761
|
return factory.updateTypeParameterDeclaration(
|
|
51755
51762
|
node,
|
|
51756
|
-
node.modifiers,
|
|
51763
|
+
visitNodes2(node.modifiers, visitExistingNodeTreeSymbols, isModifier),
|
|
51757
51764
|
setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
|
|
51758
51765
|
visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
|
|
51759
51766
|
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
|
|
51760
51767
|
);
|
|
51761
51768
|
}
|
|
51762
|
-
if (isIndexedAccessTypeNode(node)
|
|
51763
|
-
const
|
|
51764
|
-
if (!
|
|
51769
|
+
if (isIndexedAccessTypeNode(node)) {
|
|
51770
|
+
const result = tryVisitIndexedAccess(node);
|
|
51771
|
+
if (!result) {
|
|
51765
51772
|
hadError = true;
|
|
51766
51773
|
return node;
|
|
51767
51774
|
}
|
|
51768
|
-
return
|
|
51775
|
+
return result;
|
|
51769
51776
|
}
|
|
51770
51777
|
if (isTypeReferenceNode(node)) {
|
|
51771
51778
|
const result = tryVisitTypeReference(node);
|
|
@@ -51785,8 +51792,8 @@ function createTypeChecker(host) {
|
|
|
51785
51792
|
return factory.updateImportTypeNode(
|
|
51786
51793
|
node,
|
|
51787
51794
|
factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)),
|
|
51788
|
-
node.attributes,
|
|
51789
|
-
node.qualifier,
|
|
51795
|
+
visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
|
|
51796
|
+
visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
|
|
51790
51797
|
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
|
|
51791
51798
|
node.isTypeOf
|
|
51792
51799
|
);
|
|
@@ -51808,25 +51815,12 @@ function createTypeChecker(host) {
|
|
|
51808
51815
|
return visited;
|
|
51809
51816
|
}
|
|
51810
51817
|
if (isTypeQueryNode(node)) {
|
|
51811
|
-
const
|
|
51812
|
-
if (
|
|
51813
|
-
const serializedName = serializeTypeName(
|
|
51814
|
-
context,
|
|
51815
|
-
node.exprName,
|
|
51816
|
-
/*isTypeOf*/
|
|
51817
|
-
true
|
|
51818
|
-
);
|
|
51819
|
-
if (serializedName) {
|
|
51820
|
-
return setTextRange2(context, serializedName, node.exprName);
|
|
51821
|
-
}
|
|
51818
|
+
const result = tryVisitTypeQuery(node);
|
|
51819
|
+
if (!result) {
|
|
51822
51820
|
hadError = true;
|
|
51823
51821
|
return node;
|
|
51824
51822
|
}
|
|
51825
|
-
return
|
|
51826
|
-
node,
|
|
51827
|
-
exprName,
|
|
51828
|
-
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
51829
|
-
);
|
|
51823
|
+
return result;
|
|
51830
51824
|
}
|
|
51831
51825
|
if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
|
|
51832
51826
|
const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
|
|
@@ -51835,8 +51829,28 @@ function createTypeChecker(host) {
|
|
|
51835
51829
|
} else {
|
|
51836
51830
|
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
|
51837
51831
|
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
|
51838
|
-
|
|
51839
|
-
|
|
51832
|
+
let literal;
|
|
51833
|
+
if (isLiteralTypeNode(computedPropertyNameType)) {
|
|
51834
|
+
literal = computedPropertyNameType.literal;
|
|
51835
|
+
} else {
|
|
51836
|
+
const evaluated = evaluateEntityNameExpression(node.expression);
|
|
51837
|
+
const literalNode = typeof evaluated.value === "string" ? factory.createStringLiteral(
|
|
51838
|
+
evaluated.value,
|
|
51839
|
+
/*isSingleQuote*/
|
|
51840
|
+
void 0
|
|
51841
|
+
) : typeof evaluated.value === "number" ? factory.createNumericLiteral(
|
|
51842
|
+
evaluated.value,
|
|
51843
|
+
/*numericLiteralFlags*/
|
|
51844
|
+
0
|
|
51845
|
+
) : void 0;
|
|
51846
|
+
if (!literalNode) {
|
|
51847
|
+
if (isImportTypeNode(computedPropertyNameType)) {
|
|
51848
|
+
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
51849
|
+
}
|
|
51850
|
+
return node;
|
|
51851
|
+
}
|
|
51852
|
+
literal = literalNode;
|
|
51853
|
+
}
|
|
51840
51854
|
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
|
51841
51855
|
return factory.createIdentifier(literal.text);
|
|
51842
51856
|
}
|
|
@@ -51853,9 +51867,9 @@ function createTypeChecker(host) {
|
|
|
51853
51867
|
hadError = hadError || introducesError;
|
|
51854
51868
|
parameterName = result;
|
|
51855
51869
|
} else {
|
|
51856
|
-
parameterName = node.parameterName;
|
|
51870
|
+
parameterName = factory.cloneNode(node.parameterName);
|
|
51857
51871
|
}
|
|
51858
|
-
return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
51872
|
+
return factory.updateTypePredicateNode(node, factory.cloneNode(node.assertsModifier), parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
51859
51873
|
}
|
|
51860
51874
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
51861
51875
|
const visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
|
|
@@ -51891,14 +51905,12 @@ function createTypeChecker(host) {
|
|
|
51891
51905
|
return node;
|
|
51892
51906
|
}
|
|
51893
51907
|
} else if (node.operator === 143 /* KeyOfKeyword */) {
|
|
51894
|
-
|
|
51895
|
-
|
|
51896
|
-
|
|
51897
|
-
|
|
51898
|
-
return node;
|
|
51899
|
-
}
|
|
51900
|
-
return factory.updateTypeOperatorNode(node, type);
|
|
51908
|
+
const result = tryVisitKeyOf(node);
|
|
51909
|
+
if (!result) {
|
|
51910
|
+
hadError = true;
|
|
51911
|
+
return node;
|
|
51901
51912
|
}
|
|
51913
|
+
return result;
|
|
51902
51914
|
}
|
|
51903
51915
|
}
|
|
51904
51916
|
return visitEachChild2(node, visitExistingNodeTreeSymbols);
|
|
@@ -51948,7 +51960,7 @@ function createTypeChecker(host) {
|
|
|
51948
51960
|
/*yieldModuleSymbol*/
|
|
51949
51961
|
true
|
|
51950
51962
|
)[0];
|
|
51951
|
-
if (parentSymbol && parentSymbol
|
|
51963
|
+
if (parentSymbol && isExternalModuleSymbol(parentSymbol)) {
|
|
51952
51964
|
name = getSpecifierForModuleSymbol(parentSymbol, context);
|
|
51953
51965
|
} else {
|
|
51954
51966
|
const targetFile = getExternalModuleFileFromDeclaration(parent);
|
|
@@ -75332,7 +75344,7 @@ function createTypeChecker(host) {
|
|
|
75332
75344
|
return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
|
|
75333
75345
|
}
|
|
75334
75346
|
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75335
|
-
const hasDefaultOnly =
|
|
75347
|
+
const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
75336
75348
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75337
75349
|
const synthType = type;
|
|
75338
75350
|
if (!synthType.defaultOnlyType) {
|
|
@@ -80559,7 +80571,7 @@ function createTypeChecker(host) {
|
|
|
80559
80571
|
});
|
|
80560
80572
|
}
|
|
80561
80573
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
80562
|
-
if (
|
|
80574
|
+
if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
80563
80575
|
return;
|
|
80564
80576
|
}
|
|
80565
80577
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -81980,7 +81992,7 @@ function createTypeChecker(host) {
|
|
|
81980
81992
|
}
|
|
81981
81993
|
}
|
|
81982
81994
|
function checkClassNameCollisionWithObject(name) {
|
|
81983
|
-
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" &&
|
|
81995
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
81984
81996
|
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
|
81985
81997
|
}
|
|
81986
81998
|
}
|
|
@@ -83061,7 +83073,7 @@ function createTypeChecker(host) {
|
|
|
83061
83073
|
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
|
83062
83074
|
}
|
|
83063
83075
|
}
|
|
83064
|
-
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ &&
|
|
83076
|
+
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83065
83077
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
|
83066
83078
|
if (exportModifier) {
|
|
83067
83079
|
error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
@@ -83271,10 +83283,8 @@ function createTypeChecker(host) {
|
|
|
83271
83283
|
}
|
|
83272
83284
|
}
|
|
83273
83285
|
}
|
|
83274
|
-
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) &&
|
|
83286
|
+
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83275
83287
|
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
83276
|
-
} else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
83277
|
-
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
|
|
83278
83288
|
}
|
|
83279
83289
|
}
|
|
83280
83290
|
if (isImportSpecifier(node)) {
|
|
@@ -83313,7 +83323,7 @@ function createTypeChecker(host) {
|
|
|
83313
83323
|
function checkImportBinding(node) {
|
|
83314
83324
|
checkCollisionsForDeclarationName(node, node.name);
|
|
83315
83325
|
checkAliasSymbol(node);
|
|
83316
|
-
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) &&
|
|
83326
|
+
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83317
83327
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
83318
83328
|
}
|
|
83319
83329
|
}
|
|
@@ -83334,7 +83344,7 @@ function createTypeChecker(host) {
|
|
|
83334
83344
|
if (validForTypeAttributes && override) {
|
|
83335
83345
|
return;
|
|
83336
83346
|
}
|
|
83337
|
-
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier &&
|
|
83347
|
+
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
83338
83348
|
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
|
83339
83349
|
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;
|
|
83340
83350
|
return grammarErrorOnNode(node, message);
|
|
@@ -83367,7 +83377,7 @@ function createTypeChecker(host) {
|
|
|
83367
83377
|
if (importClause.namedBindings) {
|
|
83368
83378
|
if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
|
|
83369
83379
|
checkImportBinding(importClause.namedBindings);
|
|
83370
|
-
if (
|
|
83380
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
|
|
83371
83381
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
83372
83382
|
}
|
|
83373
83383
|
} else {
|
|
@@ -83407,7 +83417,7 @@ function createTypeChecker(host) {
|
|
|
83407
83417
|
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
|
83408
83418
|
}
|
|
83409
83419
|
} else {
|
|
83410
|
-
if (5 /* ES2015 */
|
|
83420
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
83411
83421
|
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);
|
|
83412
83422
|
}
|
|
83413
83423
|
}
|
|
@@ -83436,7 +83446,7 @@ function createTypeChecker(host) {
|
|
|
83436
83446
|
} else if (node.exportClause) {
|
|
83437
83447
|
checkAliasSymbol(node.exportClause);
|
|
83438
83448
|
}
|
|
83439
|
-
if (
|
|
83449
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83440
83450
|
if (node.exportClause) {
|
|
83441
83451
|
if (getESModuleInterop(compilerOptions)) {
|
|
83442
83452
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
@@ -83489,7 +83499,7 @@ function createTypeChecker(host) {
|
|
|
83489
83499
|
markLinkedReferences(node, 7 /* ExportSpecifier */);
|
|
83490
83500
|
}
|
|
83491
83501
|
} else {
|
|
83492
|
-
if (getESModuleInterop(compilerOptions) &&
|
|
83502
|
+
if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && idText(node.propertyName || node.name) === "default") {
|
|
83493
83503
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
83494
83504
|
}
|
|
83495
83505
|
}
|
|
@@ -83515,7 +83525,7 @@ function createTypeChecker(host) {
|
|
|
83515
83525
|
if (typeAnnotationNode) {
|
|
83516
83526
|
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
|
|
83517
83527
|
}
|
|
83518
|
-
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax &&
|
|
83528
|
+
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
|
|
83519
83529
|
if (node.expression.kind === 80 /* Identifier */) {
|
|
83520
83530
|
const id = node.expression;
|
|
83521
83531
|
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
|
@@ -83595,7 +83605,7 @@ function createTypeChecker(host) {
|
|
|
83595
83605
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
83596
83606
|
}
|
|
83597
83607
|
if (node.isExportEquals) {
|
|
83598
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ &&
|
|
83608
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
|
|
83599
83609
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
83600
83610
|
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
|
83601
83611
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
@@ -86093,7 +86103,7 @@ function createTypeChecker(host) {
|
|
|
86093
86103
|
break;
|
|
86094
86104
|
case 95 /* ExportKeyword */:
|
|
86095
86105
|
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
|
|
86096
|
-
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ &&
|
|
86106
|
+
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
86097
86107
|
return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
86098
86108
|
}
|
|
86099
86109
|
if (flags & 32 /* Export */) {
|
|
@@ -87002,7 +87012,7 @@ function createTypeChecker(host) {
|
|
|
87002
87012
|
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;
|
|
87003
87013
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
87004
87014
|
}
|
|
87005
|
-
if (
|
|
87015
|
+
if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
|
|
87006
87016
|
checkESModuleMarker(node.name);
|
|
87007
87017
|
}
|
|
87008
87018
|
return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
|
|
@@ -87503,9 +87513,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
|
|
|
87503
87513
|
isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
|
|
87504
87514
|
fileExists: (fileName) => host.fileExists(fileName),
|
|
87505
87515
|
getFileIncludeReasons: () => host.getFileIncludeReasons(),
|
|
87506
|
-
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
87507
|
-
getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
|
|
87508
|
-
getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
|
|
87516
|
+
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
87509
87517
|
};
|
|
87510
87518
|
}
|
|
87511
87519
|
var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
|
@@ -107170,7 +107178,7 @@ function transformModule(context) {
|
|
|
107170
107178
|
case 354 /* PartiallyEmittedExpression */:
|
|
107171
107179
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
107172
107180
|
case 213 /* CallExpression */:
|
|
107173
|
-
if (isImportCall(node) &&
|
|
107181
|
+
if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
|
|
107174
107182
|
return visitImportCallExpression(node);
|
|
107175
107183
|
}
|
|
107176
107184
|
break;
|
|
@@ -110165,8 +110173,8 @@ function transformECMAScriptModule(context) {
|
|
|
110165
110173
|
}
|
|
110166
110174
|
}
|
|
110167
110175
|
|
|
110168
|
-
// src/compiler/transformers/module/
|
|
110169
|
-
function
|
|
110176
|
+
// src/compiler/transformers/module/node.ts
|
|
110177
|
+
function transformNodeModule(context) {
|
|
110170
110178
|
const previousOnSubstituteNode = context.onSubstituteNode;
|
|
110171
110179
|
const previousOnEmitNode = context.onEmitNode;
|
|
110172
110180
|
const esmTransform = transformECMAScriptModule(context);
|
|
@@ -110177,7 +110185,6 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
110177
110185
|
const cjsTransform = transformModule(context);
|
|
110178
110186
|
const cjsOnSubstituteNode = context.onSubstituteNode;
|
|
110179
110187
|
const cjsOnEmitNode = context.onEmitNode;
|
|
110180
|
-
const getEmitModuleFormatOfFile = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
|
110181
110188
|
context.onSubstituteNode = onSubstituteNode;
|
|
110182
110189
|
context.onEmitNode = onEmitNode;
|
|
110183
110190
|
context.enableSubstitution(307 /* SourceFile */);
|
|
@@ -110192,7 +110199,7 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
110192
110199
|
if (!currentSourceFile) {
|
|
110193
110200
|
return previousOnSubstituteNode(hint, node);
|
|
110194
110201
|
}
|
|
110195
|
-
if (
|
|
110202
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
110196
110203
|
return esmOnSubstituteNode(hint, node);
|
|
110197
110204
|
}
|
|
110198
110205
|
return cjsOnSubstituteNode(hint, node);
|
|
@@ -110205,13 +110212,13 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
110205
110212
|
if (!currentSourceFile) {
|
|
110206
110213
|
return previousOnEmitNode(hint, node, emitCallback);
|
|
110207
110214
|
}
|
|
110208
|
-
if (
|
|
110215
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
110209
110216
|
return esmOnEmitNode(hint, node, emitCallback);
|
|
110210
110217
|
}
|
|
110211
110218
|
return cjsOnEmitNode(hint, node, emitCallback);
|
|
110212
110219
|
}
|
|
110213
110220
|
function getModuleTransformForFile(file) {
|
|
110214
|
-
return
|
|
110221
|
+
return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
|
|
110215
110222
|
}
|
|
110216
110223
|
function transformSourceFile(node) {
|
|
110217
110224
|
if (node.isDeclarationFile) {
|
|
@@ -112331,18 +112338,17 @@ function isProcessedComponent(node) {
|
|
|
112331
112338
|
// src/compiler/transformer.ts
|
|
112332
112339
|
function getModuleTransformer(moduleKind) {
|
|
112333
112340
|
switch (moduleKind) {
|
|
112334
|
-
case 200 /* Preserve */:
|
|
112335
|
-
return transformECMAScriptModule;
|
|
112336
112341
|
case 99 /* ESNext */:
|
|
112337
112342
|
case 7 /* ES2022 */:
|
|
112338
112343
|
case 6 /* ES2020 */:
|
|
112339
112344
|
case 5 /* ES2015 */:
|
|
112340
|
-
case
|
|
112341
|
-
|
|
112342
|
-
case 1 /* CommonJS */:
|
|
112343
|
-
return transformImpliedNodeFormatDependentModule;
|
|
112345
|
+
case 200 /* Preserve */:
|
|
112346
|
+
return transformECMAScriptModule;
|
|
112344
112347
|
case 4 /* System */:
|
|
112345
112348
|
return transformSystemModule;
|
|
112349
|
+
case 100 /* Node16 */:
|
|
112350
|
+
case 199 /* NodeNext */:
|
|
112351
|
+
return transformNodeModule;
|
|
112346
112352
|
default:
|
|
112347
112353
|
return transformModule;
|
|
112348
112354
|
}
|
|
@@ -113061,7 +113067,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
113061
113067
|
newLine: compilerOptions.newLine,
|
|
113062
113068
|
noEmitHelpers: compilerOptions.noEmitHelpers,
|
|
113063
113069
|
module: getEmitModuleKind(compilerOptions),
|
|
113064
|
-
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
|
113065
113070
|
target: getEmitScriptTarget(compilerOptions),
|
|
113066
113071
|
sourceMap: compilerOptions.sourceMap,
|
|
113067
113072
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -113124,7 +113129,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
113124
113129
|
newLine: compilerOptions.newLine,
|
|
113125
113130
|
noEmitHelpers: true,
|
|
113126
113131
|
module: compilerOptions.module,
|
|
113127
|
-
moduleResolution: compilerOptions.moduleResolution,
|
|
113128
113132
|
target: compilerOptions.target,
|
|
113129
113133
|
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
|
113130
113134
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -118582,6 +118586,9 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
|
|
|
118582
118586
|
function getModeForFileReference(ref, containingFileMode) {
|
|
118583
118587
|
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
118584
118588
|
}
|
|
118589
|
+
function getModeForResolutionAtIndex(file, index, compilerOptions) {
|
|
118590
|
+
return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
|
|
118591
|
+
}
|
|
118585
118592
|
function isExclusivelyTypeOnlyImportOrExport(decl) {
|
|
118586
118593
|
var _a;
|
|
118587
118594
|
if (isExportDeclaration(decl)) {
|
|
@@ -118596,6 +118603,7 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
|
|
|
118596
118603
|
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
|
118597
118604
|
}
|
|
118598
118605
|
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
118606
|
+
var _a;
|
|
118599
118607
|
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
|
118600
118608
|
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
|
118601
118609
|
if (isTypeOnly) {
|
|
@@ -118611,28 +118619,19 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
|
118611
118619
|
return override;
|
|
118612
118620
|
}
|
|
118613
118621
|
}
|
|
118614
|
-
if (compilerOptions &&
|
|
118615
|
-
return
|
|
118622
|
+
if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
|
118623
|
+
return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
|
|
118624
|
+
usage.parent,
|
|
118625
|
+
/*requireStringLiteralLikeArgument*/
|
|
118626
|
+
false
|
|
118627
|
+
) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
118616
118628
|
}
|
|
118617
|
-
|
|
118618
|
-
|
|
118619
|
-
|
|
118620
|
-
if (!compilerOptions) {
|
|
118621
|
-
return void 0;
|
|
118629
|
+
if (file.impliedNodeFormat === void 0) return void 0;
|
|
118630
|
+
if (file.impliedNodeFormat !== 99 /* ESNext */) {
|
|
118631
|
+
return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
118622
118632
|
}
|
|
118623
118633
|
const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
|
|
118624
|
-
|
|
118625
|
-
usage.parent,
|
|
118626
|
-
/*requireStringLiteralLikeArgument*/
|
|
118627
|
-
false
|
|
118628
|
-
)) {
|
|
118629
|
-
return 1 /* CommonJS */;
|
|
118630
|
-
}
|
|
118631
|
-
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
|
118632
|
-
return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
118633
|
-
}
|
|
118634
|
-
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
|
118635
|
-
return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
|
|
118634
|
+
return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
118636
118635
|
}
|
|
118637
118636
|
function getResolutionModeOverride(node, grammarErrorOnNode) {
|
|
118638
118637
|
if (!node) return void 0;
|
|
@@ -118689,7 +118688,7 @@ function getTypeReferenceResolutionName(entry) {
|
|
|
118689
118688
|
}
|
|
118690
118689
|
var typeReferenceResolutionNameAndModeGetter = {
|
|
118691
118690
|
getName: getTypeReferenceResolutionName,
|
|
118692
|
-
getMode: (entry, file
|
|
118691
|
+
getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
|
|
118693
118692
|
};
|
|
118694
118693
|
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
118695
118694
|
return {
|
|
@@ -118859,7 +118858,13 @@ function getConfigFileParsingDiagnostics(configFileParseResult) {
|
|
|
118859
118858
|
return configFileParseResult.options.configFile ? [...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] : configFileParseResult.errors;
|
|
118860
118859
|
}
|
|
118861
118860
|
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
118862
|
-
|
|
118861
|
+
switch (getEmitModuleResolutionKind(options)) {
|
|
118862
|
+
case 3 /* Node16 */:
|
|
118863
|
+
case 99 /* NodeNext */:
|
|
118864
|
+
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;
|
|
118865
|
+
default:
|
|
118866
|
+
return void 0;
|
|
118867
|
+
}
|
|
118863
118868
|
function lookupFromPackageJson() {
|
|
118864
118869
|
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
118865
118870
|
const packageJsonLocations = [];
|
|
@@ -119318,8 +119323,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119318
119323
|
isSourceFileFromExternalLibrary,
|
|
119319
119324
|
isSourceFileDefaultLibrary,
|
|
119320
119325
|
getModeForUsageLocation: getModeForUsageLocation2,
|
|
119321
|
-
|
|
119322
|
-
getModeForResolutionAtIndex,
|
|
119326
|
+
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
119323
119327
|
getSourceFileFromReference,
|
|
119324
119328
|
getLibFileFromReference,
|
|
119325
119329
|
sourceFileToPackageName,
|
|
@@ -119347,11 +119351,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119347
119351
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
119348
119352
|
isSourceOfProjectReferenceRedirect,
|
|
119349
119353
|
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
119350
|
-
getCompilerOptionsForFile,
|
|
119351
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
119352
|
-
getEmitModuleFormatOfFile,
|
|
119353
|
-
getImpliedNodeFormatForEmit,
|
|
119354
|
-
shouldTransformImportCall,
|
|
119355
119354
|
emitBuildInfo,
|
|
119356
119355
|
fileExists,
|
|
119357
119356
|
readFile,
|
|
@@ -119934,10 +119933,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119934
119933
|
getSymlinkCache,
|
|
119935
119934
|
writeFile: writeFileCallback || writeFile2,
|
|
119936
119935
|
isEmitBlocked,
|
|
119937
|
-
shouldTransformImportCall,
|
|
119938
|
-
getEmitModuleFormatOfFile,
|
|
119939
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
119940
|
-
getModeForResolutionAtIndex,
|
|
119941
119936
|
readFile: (f) => host.readFile(f),
|
|
119942
119937
|
fileExists: (f) => {
|
|
119943
119938
|
const path = toPath3(f);
|
|
@@ -120987,14 +120982,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120987
120982
|
const resolvedTypeReferenceDirective = resolutions[index];
|
|
120988
120983
|
const fileName = ref.fileName;
|
|
120989
120984
|
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
|
120990
|
-
const mode = ref.resolutionMode ||
|
|
120985
|
+
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
120991
120986
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
|
120992
120987
|
}
|
|
120993
120988
|
}
|
|
120994
|
-
function getCompilerOptionsForFile(file) {
|
|
120995
|
-
var _a2;
|
|
120996
|
-
return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
120997
|
-
}
|
|
120998
120989
|
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
120999
120990
|
var _a2, _b2;
|
|
121000
120991
|
(_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 });
|
|
@@ -121095,12 +121086,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121095
121086
|
return host.getCanonicalFileName(fileName);
|
|
121096
121087
|
}
|
|
121097
121088
|
function processImportedModules(file) {
|
|
121089
|
+
var _a2;
|
|
121098
121090
|
collectExternalModuleReferences(file);
|
|
121099
121091
|
if (file.imports.length || file.moduleAugmentations.length) {
|
|
121100
121092
|
const moduleNames = getModuleNames(file);
|
|
121101
121093
|
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
121102
121094
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
121103
|
-
const optionsForFile =
|
|
121095
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
121104
121096
|
const resolutionsInFile = createModeAwareCache();
|
|
121105
121097
|
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
121106
121098
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
@@ -121523,7 +121515,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121523
121515
|
}
|
|
121524
121516
|
return Version.zero;
|
|
121525
121517
|
}
|
|
121526
|
-
function checkDeprecations(deprecatedIn, removedIn, createDiagnostic, fn) {
|
|
121518
|
+
function checkDeprecations(deprecatedIn, stopsWorkingIn, removedIn, createDiagnostic, fn) {
|
|
121527
121519
|
const deprecatedInVersion = new Version(deprecatedIn);
|
|
121528
121520
|
const removedInVersion = new Version(removedIn);
|
|
121529
121521
|
const typescriptVersion = new Version(typeScriptVersion2 || versionMajorMinor);
|
|
@@ -121540,9 +121532,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121540
121532
|
}
|
|
121541
121533
|
} else {
|
|
121542
121534
|
if (value === void 0) {
|
|
121543
|
-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name,
|
|
121535
|
+
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name, stopsWorkingIn, deprecatedIn);
|
|
121544
121536
|
} else {
|
|
121545
|
-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value,
|
|
121537
|
+
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value, stopsWorkingIn, deprecatedIn);
|
|
121546
121538
|
}
|
|
121547
121539
|
}
|
|
121548
121540
|
});
|
|
@@ -121578,7 +121570,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121578
121570
|
);
|
|
121579
121571
|
}
|
|
121580
121572
|
}
|
|
121581
|
-
checkDeprecations("5.0", "5.5", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
121573
|
+
checkDeprecations("5.0", "5.5", "6.0", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
121582
121574
|
if (options.target === 0 /* ES3 */) {
|
|
121583
121575
|
createDeprecatedDiagnostic("target", "ES3");
|
|
121584
121576
|
}
|
|
@@ -121630,7 +121622,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121630
121622
|
function createDiagnostic(_name, _value, _useInstead, message, ...args) {
|
|
121631
121623
|
createDiagnosticForReference(parentFile, index, message, ...args);
|
|
121632
121624
|
}
|
|
121633
|
-
checkDeprecations("5.0", "5.5", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
121625
|
+
checkDeprecations("5.0", "5.5", "6.0", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
121634
121626
|
if (ref.prepend) {
|
|
121635
121627
|
createDeprecatedDiagnostic("prepend");
|
|
121636
121628
|
}
|
|
@@ -121656,7 +121648,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121656
121648
|
redirectInfo = cachedChain.redirectInfo;
|
|
121657
121649
|
} else {
|
|
121658
121650
|
reasons == null ? void 0 : reasons.forEach(processReason);
|
|
121659
|
-
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file
|
|
121651
|
+
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
|
121660
121652
|
}
|
|
121661
121653
|
if (fileProcessingReason) processReason(fileProcessingReason);
|
|
121662
121654
|
const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
|
|
@@ -122014,53 +122006,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122014
122006
|
return symlinks;
|
|
122015
122007
|
}
|
|
122016
122008
|
function getModeForUsageLocation2(file, usage) {
|
|
122017
|
-
|
|
122018
|
-
|
|
122019
|
-
|
|
122020
|
-
return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
|
122009
|
+
var _a2;
|
|
122010
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
122011
|
+
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
|
122021
122012
|
}
|
|
122022
|
-
function
|
|
122013
|
+
function getModeForResolutionAtIndex2(file, index) {
|
|
122023
122014
|
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
|
122024
122015
|
}
|
|
122025
|
-
function getDefaultResolutionModeForFile2(sourceFile) {
|
|
122026
|
-
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
122027
|
-
}
|
|
122028
|
-
function getImpliedNodeFormatForEmit(sourceFile) {
|
|
122029
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
122030
|
-
}
|
|
122031
|
-
function getEmitModuleFormatOfFile(sourceFile) {
|
|
122032
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
122033
|
-
}
|
|
122034
|
-
function shouldTransformImportCall(sourceFile) {
|
|
122035
|
-
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
122036
|
-
}
|
|
122037
|
-
}
|
|
122038
|
-
function shouldTransformImportCallWorker(sourceFile, options) {
|
|
122039
|
-
const moduleKind = getEmitModuleKind(options);
|
|
122040
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
|
|
122041
|
-
return false;
|
|
122042
|
-
}
|
|
122043
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
|
|
122044
|
-
}
|
|
122045
|
-
function getEmitModuleFormatOfFileWorker(sourceFile, options) {
|
|
122046
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
|
122047
|
-
}
|
|
122048
|
-
function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
|
|
122049
|
-
var _a, _b;
|
|
122050
|
-
const moduleKind = getEmitModuleKind(options);
|
|
122051
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
122052
|
-
return sourceFile.impliedNodeFormat;
|
|
122053
|
-
}
|
|
122054
|
-
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
|
|
122055
|
-
return 1 /* CommonJS */;
|
|
122056
|
-
}
|
|
122057
|
-
if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
|
|
122058
|
-
return 99 /* ESNext */;
|
|
122059
|
-
}
|
|
122060
|
-
return void 0;
|
|
122061
|
-
}
|
|
122062
|
-
function getDefaultResolutionModeForFileWorker(sourceFile, options) {
|
|
122063
|
-
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
|
|
122064
122016
|
}
|
|
122065
122017
|
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
|
122066
122018
|
let setOfDeclarationDirectories;
|
|
@@ -125244,10 +125196,10 @@ function explainFiles(program, write) {
|
|
|
125244
125196
|
for (const file of program.getSourceFiles()) {
|
|
125245
125197
|
write(`${toFileName(file, relativeFileName)}`);
|
|
125246
125198
|
(_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
|
125247
|
-
(_b = explainIfFileIsRedirectAndImpliedFormat(file,
|
|
125199
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
|
125248
125200
|
}
|
|
125249
125201
|
}
|
|
125250
|
-
function explainIfFileIsRedirectAndImpliedFormat(file,
|
|
125202
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
125251
125203
|
var _a;
|
|
125252
125204
|
let result;
|
|
125253
125205
|
if (file.path !== file.resolvedPath) {
|
|
@@ -125267,7 +125219,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConverto
|
|
|
125267
125219
|
));
|
|
125268
125220
|
}
|
|
125269
125221
|
if (isExternalOrCommonJsModule(file)) {
|
|
125270
|
-
switch (
|
|
125222
|
+
switch (file.impliedNodeFormat) {
|
|
125271
125223
|
case 99 /* ESNext */:
|
|
125272
125224
|
if (file.packageJsonScope) {
|
|
125273
125225
|
(result ?? (result = [])).push(chainDiagnosticMessages(
|