typescript 5.5.1-rc → 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 +129 -202
- package/lib/typescript.d.ts +22 -89
- package/lib/typescript.js +199 -314
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -258,7 +258,6 @@ __export(typescript_exports, {
|
|
|
258
258
|
canHaveJSDoc: () => canHaveJSDoc,
|
|
259
259
|
canHaveLocals: () => canHaveLocals,
|
|
260
260
|
canHaveModifiers: () => canHaveModifiers,
|
|
261
|
-
canHaveModuleSpecifier: () => canHaveModuleSpecifier,
|
|
262
261
|
canHaveSymbol: () => canHaveSymbol,
|
|
263
262
|
canIncludeBindAndCheckDiagnsotics: () => canIncludeBindAndCheckDiagnsotics,
|
|
264
263
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
@@ -736,7 +735,6 @@ __export(typescript_exports, {
|
|
|
736
735
|
getDefaultLibFilePath: () => getDefaultLibFilePath,
|
|
737
736
|
getDefaultLikeExportInfo: () => getDefaultLikeExportInfo,
|
|
738
737
|
getDefaultLikeExportNameFromDeclaration: () => getDefaultLikeExportNameFromDeclaration,
|
|
739
|
-
getDefaultResolutionModeForFileWorker: () => getDefaultResolutionModeForFileWorker,
|
|
740
738
|
getDiagnosticText: () => getDiagnosticText,
|
|
741
739
|
getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
|
|
742
740
|
getDirectoryPath: () => getDirectoryPath,
|
|
@@ -767,7 +765,6 @@ __export(typescript_exports, {
|
|
|
767
765
|
getEmitFlags: () => getEmitFlags,
|
|
768
766
|
getEmitHelpers: () => getEmitHelpers,
|
|
769
767
|
getEmitModuleDetectionKind: () => getEmitModuleDetectionKind,
|
|
770
|
-
getEmitModuleFormatOfFileWorker: () => getEmitModuleFormatOfFileWorker,
|
|
771
768
|
getEmitModuleKind: () => getEmitModuleKind,
|
|
772
769
|
getEmitModuleResolutionKind: () => getEmitModuleResolutionKind,
|
|
773
770
|
getEmitScriptTarget: () => getEmitScriptTarget,
|
|
@@ -818,7 +815,6 @@ __export(typescript_exports, {
|
|
|
818
815
|
getIdentifierGeneratedImportReference: () => getIdentifierGeneratedImportReference,
|
|
819
816
|
getIdentifierTypeArguments: () => getIdentifierTypeArguments,
|
|
820
817
|
getImmediatelyInvokedFunctionExpression: () => getImmediatelyInvokedFunctionExpression,
|
|
821
|
-
getImpliedNodeFormatForEmitWorker: () => getImpliedNodeFormatForEmitWorker,
|
|
822
818
|
getImpliedNodeFormatForFile: () => getImpliedNodeFormatForFile,
|
|
823
819
|
getImpliedNodeFormatForFileWorker: () => getImpliedNodeFormatForFileWorker,
|
|
824
820
|
getImportNeedsImportDefaultHelper: () => getImportNeedsImportDefaultHelper,
|
|
@@ -1178,7 +1174,6 @@ __export(typescript_exports, {
|
|
|
1178
1174
|
importDefaultHelper: () => importDefaultHelper,
|
|
1179
1175
|
importFromModuleSpecifier: () => importFromModuleSpecifier,
|
|
1180
1176
|
importStarHelper: () => importStarHelper,
|
|
1181
|
-
importSyntaxAffectsModuleResolution: () => importSyntaxAffectsModuleResolution,
|
|
1182
1177
|
indexOfAnyCharCode: () => indexOfAnyCharCode,
|
|
1183
1178
|
indexOfNode: () => indexOfNode,
|
|
1184
1179
|
indicesOf: () => indicesOf,
|
|
@@ -2273,11 +2268,11 @@ __export(typescript_exports, {
|
|
|
2273
2268
|
transformESDecorators: () => transformESDecorators,
|
|
2274
2269
|
transformESNext: () => transformESNext,
|
|
2275
2270
|
transformGenerators: () => transformGenerators,
|
|
2276
|
-
transformImpliedNodeFormatDependentModule: () => transformImpliedNodeFormatDependentModule,
|
|
2277
2271
|
transformJsx: () => transformJsx,
|
|
2278
2272
|
transformLegacyDecorators: () => transformLegacyDecorators,
|
|
2279
2273
|
transformModule: () => transformModule,
|
|
2280
2274
|
transformNamedEvaluation: () => transformNamedEvaluation,
|
|
2275
|
+
transformNodeModule: () => transformNodeModule,
|
|
2281
2276
|
transformNodes: () => transformNodes,
|
|
2282
2277
|
transformSystemModule: () => transformSystemModule,
|
|
2283
2278
|
transformTypeScript: () => transformTypeScript,
|
|
@@ -2371,7 +2366,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2371
2366
|
|
|
2372
2367
|
// src/compiler/corePublic.ts
|
|
2373
2368
|
var versionMajorMinor = "5.5";
|
|
2374
|
-
var version = "5.5.
|
|
2369
|
+
var version = "5.5.2";
|
|
2375
2370
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2376
2371
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2377
2372
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9506,7 +9501,6 @@ var Diagnostics = {
|
|
|
9506
9501
|
_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 }'."),
|
|
9507
9502
|
_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."),
|
|
9508
9503
|
_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 }'."),
|
|
9509
|
-
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'."),
|
|
9510
9504
|
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."),
|
|
9511
9505
|
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."),
|
|
9512
9506
|
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."),
|
|
@@ -16232,6 +16226,9 @@ function createSymbolTable(symbols) {
|
|
|
16232
16226
|
function isTransientSymbol(symbol) {
|
|
16233
16227
|
return (symbol.flags & 33554432 /* Transient */) !== 0;
|
|
16234
16228
|
}
|
|
16229
|
+
function isExternalModuleSymbol(moduleSymbol) {
|
|
16230
|
+
return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.escapedName.charCodeAt(0) === 34 /* doubleQuote */;
|
|
16231
|
+
}
|
|
16235
16232
|
var stringWriter = createSingleLineStringWriter();
|
|
16236
16233
|
function createSingleLineStringWriter() {
|
|
16237
16234
|
var str = "";
|
|
@@ -18630,23 +18627,6 @@ function isFunctionSymbol(symbol) {
|
|
|
18630
18627
|
const decl = symbol.valueDeclaration;
|
|
18631
18628
|
return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
|
|
18632
18629
|
}
|
|
18633
|
-
function canHaveModuleSpecifier(node) {
|
|
18634
|
-
switch (node == null ? void 0 : node.kind) {
|
|
18635
|
-
case 260 /* VariableDeclaration */:
|
|
18636
|
-
case 208 /* BindingElement */:
|
|
18637
|
-
case 272 /* ImportDeclaration */:
|
|
18638
|
-
case 278 /* ExportDeclaration */:
|
|
18639
|
-
case 271 /* ImportEqualsDeclaration */:
|
|
18640
|
-
case 273 /* ImportClause */:
|
|
18641
|
-
case 280 /* NamespaceExport */:
|
|
18642
|
-
case 274 /* NamespaceImport */:
|
|
18643
|
-
case 281 /* ExportSpecifier */:
|
|
18644
|
-
case 276 /* ImportSpecifier */:
|
|
18645
|
-
case 205 /* ImportType */:
|
|
18646
|
-
return true;
|
|
18647
|
-
}
|
|
18648
|
-
return false;
|
|
18649
|
-
}
|
|
18650
18630
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
18651
18631
|
var _a, _b;
|
|
18652
18632
|
switch (node.kind) {
|
|
@@ -21661,8 +21641,8 @@ function walkTreeForJSXTags(node) {
|
|
|
21661
21641
|
function isFileModuleFromUsingJSXTag(file) {
|
|
21662
21642
|
return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
|
|
21663
21643
|
}
|
|
21664
|
-
function isFileForcedToBeModuleByFormat(file
|
|
21665
|
-
return (
|
|
21644
|
+
function isFileForcedToBeModuleByFormat(file) {
|
|
21645
|
+
return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
|
|
21666
21646
|
}
|
|
21667
21647
|
function getSetExternalModuleIndicator(options) {
|
|
21668
21648
|
switch (getEmitModuleDetectionKind(options)) {
|
|
@@ -21681,14 +21661,10 @@ function getSetExternalModuleIndicator(options) {
|
|
|
21681
21661
|
}
|
|
21682
21662
|
checks.push(isFileForcedToBeModuleByFormat);
|
|
21683
21663
|
const combined = or(...checks);
|
|
21684
|
-
const callback = (file) => void (file.externalModuleIndicator = combined(file
|
|
21664
|
+
const callback = (file) => void (file.externalModuleIndicator = combined(file));
|
|
21685
21665
|
return callback;
|
|
21686
21666
|
}
|
|
21687
21667
|
}
|
|
21688
|
-
function importSyntaxAffectsModuleResolution(options) {
|
|
21689
|
-
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
21690
|
-
return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
|
|
21691
|
-
}
|
|
21692
21668
|
function createComputedCompilerOptions(options) {
|
|
21693
21669
|
return options;
|
|
21694
21670
|
}
|
|
@@ -23414,7 +23390,7 @@ function createNameResolver({
|
|
|
23414
23390
|
}
|
|
23415
23391
|
break;
|
|
23416
23392
|
}
|
|
23417
|
-
if (isSelfReferenceLocation(location)) {
|
|
23393
|
+
if (isSelfReferenceLocation(location, lastLocation)) {
|
|
23418
23394
|
lastSelfReferenceLocation = location;
|
|
23419
23395
|
}
|
|
23420
23396
|
lastLocation = location;
|
|
@@ -23515,8 +23491,10 @@ function createNameResolver({
|
|
|
23515
23491
|
}
|
|
23516
23492
|
return !getImmediatelyInvokedFunctionExpression(location);
|
|
23517
23493
|
}
|
|
23518
|
-
function isSelfReferenceLocation(node) {
|
|
23494
|
+
function isSelfReferenceLocation(node, lastLocation) {
|
|
23519
23495
|
switch (node.kind) {
|
|
23496
|
+
case 169 /* Parameter */:
|
|
23497
|
+
return !!lastLocation && lastLocation === node.name;
|
|
23520
23498
|
case 262 /* FunctionDeclaration */:
|
|
23521
23499
|
case 263 /* ClassDeclaration */:
|
|
23522
23500
|
case 264 /* InterfaceDeclaration */:
|
|
@@ -31048,7 +31026,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
|
|
|
31048
31026
|
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
31049
31027
|
let namedBindings;
|
|
31050
31028
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
31051
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ ||
|
|
31029
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
31052
31030
|
const helpers = getEmitHelpers(sourceFile);
|
|
31053
31031
|
if (helpers) {
|
|
31054
31032
|
const helperNames = [];
|
|
@@ -31113,7 +31091,8 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
|
|
|
31113
31091
|
if (externalHelpersModuleName) {
|
|
31114
31092
|
return externalHelpersModuleName;
|
|
31115
31093
|
}
|
|
31116
|
-
|
|
31094
|
+
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
31095
|
+
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
|
|
31117
31096
|
if (!create) {
|
|
31118
31097
|
const helpers = getEmitHelpers(node);
|
|
31119
31098
|
if (helpers) {
|
|
@@ -48823,15 +48802,13 @@ var RelativePreference = /* @__PURE__ */ ((RelativePreference2) => {
|
|
|
48823
48802
|
RelativePreference2[RelativePreference2["ExternalNonRelative"] = 3] = "ExternalNonRelative";
|
|
48824
48803
|
return RelativePreference2;
|
|
48825
48804
|
})(RelativePreference || {});
|
|
48826
|
-
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding },
|
|
48805
|
+
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
|
48827
48806
|
const filePreferredEnding = getPreferredEnding();
|
|
48828
48807
|
return {
|
|
48829
48808
|
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 */,
|
|
48830
48809
|
getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
|
|
48831
|
-
const
|
|
48832
|
-
|
|
48833
|
-
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
48834
|
-
if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
|
|
48810
|
+
const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
|
48811
|
+
if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
|
|
48835
48812
|
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
|
48836
48813
|
return [3 /* TsExtension */, 2 /* JsExtension */];
|
|
48837
48814
|
}
|
|
@@ -48862,19 +48839,19 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
|
|
|
48862
48839
|
}
|
|
48863
48840
|
return getModuleSpecifierEndingPreference(
|
|
48864
48841
|
importModuleSpecifierEnding,
|
|
48865
|
-
resolutionMode ??
|
|
48842
|
+
resolutionMode ?? importingSourceFile.impliedNodeFormat,
|
|
48866
48843
|
compilerOptions,
|
|
48867
48844
|
isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
|
|
48868
48845
|
);
|
|
48869
48846
|
}
|
|
48870
48847
|
}
|
|
48871
48848
|
function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, oldImportSpecifier, options = {}) {
|
|
48872
|
-
const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({},
|
|
48849
|
+
const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options);
|
|
48873
48850
|
if (res === oldImportSpecifier) return void 0;
|
|
48874
48851
|
return res;
|
|
48875
48852
|
}
|
|
48876
48853
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, options = {}) {
|
|
48877
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({},
|
|
48854
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile), {}, options);
|
|
48878
48855
|
}
|
|
48879
48856
|
function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences, options = {}) {
|
|
48880
48857
|
const info = getInfo(importingSourceFile.fileName, host);
|
|
@@ -48904,7 +48881,7 @@ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importin
|
|
|
48904
48881
|
/*packageNameOnly*/
|
|
48905
48882
|
void 0,
|
|
48906
48883
|
options.overrideImportMode
|
|
48907
|
-
)) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode ||
|
|
48884
|
+
)) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
48908
48885
|
}
|
|
48909
48886
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options = {}) {
|
|
48910
48887
|
const result = tryGetModuleSpecifiersFromCacheWorker(
|
|
@@ -48975,21 +48952,17 @@ function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName,
|
|
|
48975
48952
|
compilerOptions,
|
|
48976
48953
|
host,
|
|
48977
48954
|
importMode,
|
|
48978
|
-
getModuleSpecifierPreferences({},
|
|
48955
|
+
getModuleSpecifierPreferences({}, compilerOptions, importingFile)
|
|
48979
48956
|
);
|
|
48980
48957
|
}
|
|
48981
48958
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
48982
48959
|
const info = getInfo(importingSourceFile.fileName, host);
|
|
48983
|
-
const preferences = getModuleSpecifierPreferences(userPreferences,
|
|
48960
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
48984
48961
|
const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
|
|
48985
48962
|
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
|
48986
48963
|
(reason) => {
|
|
48987
48964
|
if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
|
|
48988
|
-
|
|
48989
|
-
const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
|
|
48990
|
-
if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
|
|
48991
|
-
return void 0;
|
|
48992
|
-
}
|
|
48965
|
+
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
|
|
48993
48966
|
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
|
48994
48967
|
return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
|
|
48995
48968
|
}
|
|
@@ -49519,7 +49492,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
49519
49492
|
if (!parts) {
|
|
49520
49493
|
return void 0;
|
|
49521
49494
|
}
|
|
49522
|
-
const preferences = getModuleSpecifierPreferences(userPreferences,
|
|
49495
|
+
const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
|
|
49523
49496
|
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
|
49524
49497
|
let moduleSpecifier = path;
|
|
49525
49498
|
let isPackageRootPath = false;
|
|
@@ -49569,7 +49542,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
49569
49542
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
49570
49543
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
|
49571
49544
|
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
|
49572
|
-
const importMode = overrideMode ||
|
|
49545
|
+
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
49573
49546
|
if (getResolvePackageJsonExports(options)) {
|
|
49574
49547
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
|
49575
49548
|
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
|
@@ -49719,9 +49692,6 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
|
|
|
49719
49692
|
function isPathRelativeToParent(path) {
|
|
49720
49693
|
return startsWith(path, "..");
|
|
49721
49694
|
}
|
|
49722
|
-
function getDefaultResolutionModeForFile(file, host, compilerOptions) {
|
|
49723
|
-
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
|
49724
|
-
}
|
|
49725
49695
|
|
|
49726
49696
|
// src/compiler/checker.ts
|
|
49727
49697
|
var ambientModuleSymbolRegex = /^".+"$/;
|
|
@@ -51928,28 +51898,22 @@ function createTypeChecker(host) {
|
|
|
51928
51898
|
function isSyntacticDefault(node) {
|
|
51929
51899
|
return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
|
|
51930
51900
|
}
|
|
51931
|
-
function
|
|
51932
|
-
return isStringLiteralLike(usage) ? host.
|
|
51901
|
+
function getUsageModeForExpression(usage) {
|
|
51902
|
+
return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
|
51933
51903
|
}
|
|
51934
51904
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
51935
51905
|
return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
|
|
51936
51906
|
}
|
|
51937
|
-
function
|
|
51938
|
-
|
|
51939
|
-
|
|
51940
|
-
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
|
51941
|
-
}
|
|
51942
|
-
return false;
|
|
51907
|
+
function isOnlyImportedAsDefault(usage) {
|
|
51908
|
+
const usageMode = getUsageModeForExpression(usage);
|
|
51909
|
+
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
|
51943
51910
|
}
|
|
51944
51911
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
51945
|
-
const usageMode = file &&
|
|
51946
|
-
if (file && usageMode !== void 0) {
|
|
51947
|
-
const
|
|
51948
|
-
if (usageMode === 99 /* ESNext */
|
|
51949
|
-
return
|
|
51950
|
-
}
|
|
51951
|
-
if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
|
|
51952
|
-
return false;
|
|
51912
|
+
const usageMode = file && getUsageModeForExpression(usage);
|
|
51913
|
+
if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
51914
|
+
const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
51915
|
+
if (usageMode === 99 /* ESNext */ || result) {
|
|
51916
|
+
return result;
|
|
51953
51917
|
}
|
|
51954
51918
|
}
|
|
51955
51919
|
if (!allowSyntheticDefaultImports) {
|
|
@@ -52008,7 +51972,7 @@ function createTypeChecker(host) {
|
|
|
52008
51972
|
if (!specifier) {
|
|
52009
51973
|
return exportDefaultSymbol;
|
|
52010
51974
|
}
|
|
52011
|
-
const hasDefaultOnly =
|
|
51975
|
+
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
|
|
52012
51976
|
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
|
52013
51977
|
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
52014
51978
|
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
|
|
@@ -52209,7 +52173,7 @@ function createTypeChecker(host) {
|
|
|
52209
52173
|
let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
52210
52174
|
if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
|
|
52211
52175
|
const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
52212
|
-
if (
|
|
52176
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
52213
52177
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
52214
52178
|
}
|
|
52215
52179
|
}
|
|
@@ -52809,7 +52773,7 @@ function createTypeChecker(host) {
|
|
|
52809
52773
|
/*requireStringLiteralLikeArgument*/
|
|
52810
52774
|
true
|
|
52811
52775
|
) ? 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);
|
|
52812
|
-
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) :
|
|
52776
|
+
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
52813
52777
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
52814
52778
|
const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
|
|
52815
52779
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
@@ -53053,7 +53017,7 @@ function createTypeChecker(host) {
|
|
|
53053
53017
|
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
53054
53018
|
}
|
|
53055
53019
|
const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
|
53056
|
-
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(
|
|
53020
|
+
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
|
|
53057
53021
|
if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
|
|
53058
53022
|
let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
53059
53023
|
if (!sigs || !sigs.length) {
|
|
@@ -55659,10 +55623,8 @@ function createTypeChecker(host) {
|
|
|
55659
55623
|
}
|
|
55660
55624
|
return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
|
|
55661
55625
|
}
|
|
55662
|
-
const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
|
|
55663
|
-
const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
|
|
55664
55626
|
const contextFile = context.enclosingFile;
|
|
55665
|
-
const resolutionMode = overrideImportMode ||
|
|
55627
|
+
const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
|
|
55666
55628
|
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
|
55667
55629
|
const links = getSymbolLinks(symbol);
|
|
55668
55630
|
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
|
@@ -56484,7 +56446,7 @@ function createTypeChecker(host) {
|
|
|
56484
56446
|
}
|
|
56485
56447
|
if (isJSDocTypeLiteral(node)) {
|
|
56486
56448
|
return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
|
|
56487
|
-
const name = isIdentifier(t.name) ? t.name : t.name.right;
|
|
56449
|
+
const name = visitNode(isIdentifier(t.name) ? t.name : t.name.right, visitExistingNodeTreeSymbols, isIdentifier);
|
|
56488
56450
|
const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
|
|
56489
56451
|
const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
|
|
56490
56452
|
return factory.createPropertySignature(
|
|
@@ -56528,7 +56490,7 @@ function createTypeChecker(host) {
|
|
|
56528
56490
|
void 0,
|
|
56529
56491
|
getEffectiveDotDotDotForParameter(p),
|
|
56530
56492
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56531
|
-
p.questionToken,
|
|
56493
|
+
factory.cloneNode(p.questionToken),
|
|
56532
56494
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56533
56495
|
/*initializer*/
|
|
56534
56496
|
void 0
|
|
@@ -56543,7 +56505,7 @@ function createTypeChecker(host) {
|
|
|
56543
56505
|
void 0,
|
|
56544
56506
|
getEffectiveDotDotDotForParameter(p),
|
|
56545
56507
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56546
|
-
p.questionToken,
|
|
56508
|
+
factory.cloneNode(p.questionToken),
|
|
56547
56509
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56548
56510
|
/*initializer*/
|
|
56549
56511
|
void 0
|
|
@@ -56562,7 +56524,7 @@ function createTypeChecker(host) {
|
|
|
56562
56524
|
if (isTypeParameterDeclaration(node)) {
|
|
56563
56525
|
return factory.updateTypeParameterDeclaration(
|
|
56564
56526
|
node,
|
|
56565
|
-
node.modifiers,
|
|
56527
|
+
visitNodes2(node.modifiers, visitExistingNodeTreeSymbols, isModifier),
|
|
56566
56528
|
setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
|
|
56567
56529
|
visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56568
56530
|
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
|
|
@@ -56594,8 +56556,8 @@ function createTypeChecker(host) {
|
|
|
56594
56556
|
return factory.updateImportTypeNode(
|
|
56595
56557
|
node,
|
|
56596
56558
|
factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)),
|
|
56597
|
-
node.attributes,
|
|
56598
|
-
node.qualifier,
|
|
56559
|
+
visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
|
|
56560
|
+
visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
|
|
56599
56561
|
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56600
56562
|
node.isTypeOf
|
|
56601
56563
|
);
|
|
@@ -56631,8 +56593,28 @@ function createTypeChecker(host) {
|
|
|
56631
56593
|
} else {
|
|
56632
56594
|
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
|
56633
56595
|
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
|
56634
|
-
|
|
56635
|
-
|
|
56596
|
+
let literal;
|
|
56597
|
+
if (isLiteralTypeNode(computedPropertyNameType)) {
|
|
56598
|
+
literal = computedPropertyNameType.literal;
|
|
56599
|
+
} else {
|
|
56600
|
+
const evaluated = evaluateEntityNameExpression(node.expression);
|
|
56601
|
+
const literalNode = typeof evaluated.value === "string" ? factory.createStringLiteral(
|
|
56602
|
+
evaluated.value,
|
|
56603
|
+
/*isSingleQuote*/
|
|
56604
|
+
void 0
|
|
56605
|
+
) : typeof evaluated.value === "number" ? factory.createNumericLiteral(
|
|
56606
|
+
evaluated.value,
|
|
56607
|
+
/*numericLiteralFlags*/
|
|
56608
|
+
0
|
|
56609
|
+
) : void 0;
|
|
56610
|
+
if (!literalNode) {
|
|
56611
|
+
if (isImportTypeNode(computedPropertyNameType)) {
|
|
56612
|
+
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
56613
|
+
}
|
|
56614
|
+
return node;
|
|
56615
|
+
}
|
|
56616
|
+
literal = literalNode;
|
|
56617
|
+
}
|
|
56636
56618
|
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
|
56637
56619
|
return factory.createIdentifier(literal.text);
|
|
56638
56620
|
}
|
|
@@ -56649,9 +56631,9 @@ function createTypeChecker(host) {
|
|
|
56649
56631
|
hadError = hadError || introducesError;
|
|
56650
56632
|
parameterName = result;
|
|
56651
56633
|
} else {
|
|
56652
|
-
parameterName = node.parameterName;
|
|
56634
|
+
parameterName = factory.cloneNode(node.parameterName);
|
|
56653
56635
|
}
|
|
56654
|
-
return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
56636
|
+
return factory.updateTypePredicateNode(node, factory.cloneNode(node.assertsModifier), parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
56655
56637
|
}
|
|
56656
56638
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
56657
56639
|
const visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
|
|
@@ -56742,7 +56724,7 @@ function createTypeChecker(host) {
|
|
|
56742
56724
|
/*yieldModuleSymbol*/
|
|
56743
56725
|
true
|
|
56744
56726
|
)[0];
|
|
56745
|
-
if (parentSymbol && parentSymbol
|
|
56727
|
+
if (parentSymbol && isExternalModuleSymbol(parentSymbol)) {
|
|
56746
56728
|
name = getSpecifierForModuleSymbol(parentSymbol, context);
|
|
56747
56729
|
} else {
|
|
56748
56730
|
const targetFile = getExternalModuleFileFromDeclaration(parent2);
|
|
@@ -80126,7 +80108,7 @@ function createTypeChecker(host) {
|
|
|
80126
80108
|
return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
|
|
80127
80109
|
}
|
|
80128
80110
|
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
80129
|
-
const hasDefaultOnly =
|
|
80111
|
+
const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
80130
80112
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
80131
80113
|
const synthType = type;
|
|
80132
80114
|
if (!synthType.defaultOnlyType) {
|
|
@@ -85353,7 +85335,7 @@ function createTypeChecker(host) {
|
|
|
85353
85335
|
});
|
|
85354
85336
|
}
|
|
85355
85337
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
85356
|
-
if (
|
|
85338
|
+
if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
85357
85339
|
return;
|
|
85358
85340
|
}
|
|
85359
85341
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -86774,7 +86756,7 @@ function createTypeChecker(host) {
|
|
|
86774
86756
|
}
|
|
86775
86757
|
}
|
|
86776
86758
|
function checkClassNameCollisionWithObject(name) {
|
|
86777
|
-
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" &&
|
|
86759
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
86778
86760
|
error2(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
|
86779
86761
|
}
|
|
86780
86762
|
}
|
|
@@ -87855,7 +87837,7 @@ function createTypeChecker(host) {
|
|
|
87855
87837
|
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
|
87856
87838
|
}
|
|
87857
87839
|
}
|
|
87858
|
-
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ &&
|
|
87840
|
+
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
87859
87841
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
|
87860
87842
|
if (exportModifier) {
|
|
87861
87843
|
error2(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
@@ -88065,10 +88047,8 @@ function createTypeChecker(host) {
|
|
|
88065
88047
|
}
|
|
88066
88048
|
}
|
|
88067
88049
|
}
|
|
88068
|
-
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) &&
|
|
88050
|
+
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
88069
88051
|
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
88070
|
-
} else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
88071
|
-
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
|
|
88072
88052
|
}
|
|
88073
88053
|
}
|
|
88074
88054
|
if (isImportSpecifier(node)) {
|
|
@@ -88107,7 +88087,7 @@ function createTypeChecker(host) {
|
|
|
88107
88087
|
function checkImportBinding(node) {
|
|
88108
88088
|
checkCollisionsForDeclarationName(node, node.name);
|
|
88109
88089
|
checkAliasSymbol(node);
|
|
88110
|
-
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) &&
|
|
88090
|
+
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
88111
88091
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
88112
88092
|
}
|
|
88113
88093
|
}
|
|
@@ -88128,7 +88108,7 @@ function createTypeChecker(host) {
|
|
|
88128
88108
|
if (validForTypeAttributes && override) {
|
|
88129
88109
|
return;
|
|
88130
88110
|
}
|
|
88131
|
-
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier &&
|
|
88111
|
+
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
88132
88112
|
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
|
88133
88113
|
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;
|
|
88134
88114
|
return grammarErrorOnNode(node, message);
|
|
@@ -88161,7 +88141,7 @@ function createTypeChecker(host) {
|
|
|
88161
88141
|
if (importClause.namedBindings) {
|
|
88162
88142
|
if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
|
|
88163
88143
|
checkImportBinding(importClause.namedBindings);
|
|
88164
|
-
if (
|
|
88144
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
|
|
88165
88145
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
88166
88146
|
}
|
|
88167
88147
|
} else {
|
|
@@ -88201,7 +88181,7 @@ function createTypeChecker(host) {
|
|
|
88201
88181
|
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
|
88202
88182
|
}
|
|
88203
88183
|
} else {
|
|
88204
|
-
if (5 /* ES2015 */
|
|
88184
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
88205
88185
|
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);
|
|
88206
88186
|
}
|
|
88207
88187
|
}
|
|
@@ -88230,7 +88210,7 @@ function createTypeChecker(host) {
|
|
|
88230
88210
|
} else if (node.exportClause) {
|
|
88231
88211
|
checkAliasSymbol(node.exportClause);
|
|
88232
88212
|
}
|
|
88233
|
-
if (
|
|
88213
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
88234
88214
|
if (node.exportClause) {
|
|
88235
88215
|
if (getESModuleInterop(compilerOptions)) {
|
|
88236
88216
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
@@ -88283,7 +88263,7 @@ function createTypeChecker(host) {
|
|
|
88283
88263
|
markLinkedReferences(node, 7 /* ExportSpecifier */);
|
|
88284
88264
|
}
|
|
88285
88265
|
} else {
|
|
88286
|
-
if (getESModuleInterop(compilerOptions) &&
|
|
88266
|
+
if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && idText(node.propertyName || node.name) === "default") {
|
|
88287
88267
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
88288
88268
|
}
|
|
88289
88269
|
}
|
|
@@ -88309,7 +88289,7 @@ function createTypeChecker(host) {
|
|
|
88309
88289
|
if (typeAnnotationNode) {
|
|
88310
88290
|
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
|
|
88311
88291
|
}
|
|
88312
|
-
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax &&
|
|
88292
|
+
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
|
|
88313
88293
|
if (node.expression.kind === 80 /* Identifier */) {
|
|
88314
88294
|
const id = node.expression;
|
|
88315
88295
|
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
|
@@ -88389,7 +88369,7 @@ function createTypeChecker(host) {
|
|
|
88389
88369
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
88390
88370
|
}
|
|
88391
88371
|
if (node.isExportEquals) {
|
|
88392
|
-
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ &&
|
|
88372
|
+
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 */)) {
|
|
88393
88373
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
88394
88374
|
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
|
88395
88375
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
@@ -90887,7 +90867,7 @@ function createTypeChecker(host) {
|
|
|
90887
90867
|
break;
|
|
90888
90868
|
case 95 /* ExportKeyword */:
|
|
90889
90869
|
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
|
|
90890
|
-
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ &&
|
|
90870
|
+
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
90891
90871
|
return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
90892
90872
|
}
|
|
90893
90873
|
if (flags & 32 /* Export */) {
|
|
@@ -91796,7 +91776,7 @@ function createTypeChecker(host) {
|
|
|
91796
91776
|
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;
|
|
91797
91777
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
91798
91778
|
}
|
|
91799
|
-
if (
|
|
91779
|
+
if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
|
|
91800
91780
|
checkESModuleMarker(node.name);
|
|
91801
91781
|
}
|
|
91802
91782
|
return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
|
|
@@ -92297,9 +92277,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
|
|
|
92297
92277
|
isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
|
|
92298
92278
|
fileExists: (fileName) => host.fileExists(fileName),
|
|
92299
92279
|
getFileIncludeReasons: () => host.getFileIncludeReasons(),
|
|
92300
|
-
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
92301
|
-
getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
|
|
92302
|
-
getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
|
|
92280
|
+
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
92303
92281
|
};
|
|
92304
92282
|
}
|
|
92305
92283
|
var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
|
@@ -112146,7 +112124,7 @@ function transformModule(context) {
|
|
|
112146
112124
|
case 354 /* PartiallyEmittedExpression */:
|
|
112147
112125
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
112148
112126
|
case 213 /* CallExpression */:
|
|
112149
|
-
if (isImportCall(node) &&
|
|
112127
|
+
if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
|
|
112150
112128
|
return visitImportCallExpression(node);
|
|
112151
112129
|
}
|
|
112152
112130
|
break;
|
|
@@ -115141,8 +115119,8 @@ function transformECMAScriptModule(context) {
|
|
|
115141
115119
|
}
|
|
115142
115120
|
}
|
|
115143
115121
|
|
|
115144
|
-
// src/compiler/transformers/module/
|
|
115145
|
-
function
|
|
115122
|
+
// src/compiler/transformers/module/node.ts
|
|
115123
|
+
function transformNodeModule(context) {
|
|
115146
115124
|
const previousOnSubstituteNode = context.onSubstituteNode;
|
|
115147
115125
|
const previousOnEmitNode = context.onEmitNode;
|
|
115148
115126
|
const esmTransform = transformECMAScriptModule(context);
|
|
@@ -115153,7 +115131,6 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115153
115131
|
const cjsTransform = transformModule(context);
|
|
115154
115132
|
const cjsOnSubstituteNode = context.onSubstituteNode;
|
|
115155
115133
|
const cjsOnEmitNode = context.onEmitNode;
|
|
115156
|
-
const getEmitModuleFormatOfFile2 = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
|
115157
115134
|
context.onSubstituteNode = onSubstituteNode;
|
|
115158
115135
|
context.onEmitNode = onEmitNode;
|
|
115159
115136
|
context.enableSubstitution(307 /* SourceFile */);
|
|
@@ -115168,7 +115145,7 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115168
115145
|
if (!currentSourceFile) {
|
|
115169
115146
|
return previousOnSubstituteNode(hint, node);
|
|
115170
115147
|
}
|
|
115171
|
-
if (
|
|
115148
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
115172
115149
|
return esmOnSubstituteNode(hint, node);
|
|
115173
115150
|
}
|
|
115174
115151
|
return cjsOnSubstituteNode(hint, node);
|
|
@@ -115181,13 +115158,13 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115181
115158
|
if (!currentSourceFile) {
|
|
115182
115159
|
return previousOnEmitNode(hint, node, emitCallback);
|
|
115183
115160
|
}
|
|
115184
|
-
if (
|
|
115161
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
115185
115162
|
return esmOnEmitNode(hint, node, emitCallback);
|
|
115186
115163
|
}
|
|
115187
115164
|
return cjsOnEmitNode(hint, node, emitCallback);
|
|
115188
115165
|
}
|
|
115189
115166
|
function getModuleTransformForFile(file) {
|
|
115190
|
-
return
|
|
115167
|
+
return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
|
|
115191
115168
|
}
|
|
115192
115169
|
function transformSourceFile(node) {
|
|
115193
115170
|
if (node.isDeclarationFile) {
|
|
@@ -117307,18 +117284,17 @@ function isProcessedComponent(node) {
|
|
|
117307
117284
|
// src/compiler/transformer.ts
|
|
117308
117285
|
function getModuleTransformer(moduleKind) {
|
|
117309
117286
|
switch (moduleKind) {
|
|
117310
|
-
case 200 /* Preserve */:
|
|
117311
|
-
return transformECMAScriptModule;
|
|
117312
117287
|
case 99 /* ESNext */:
|
|
117313
117288
|
case 7 /* ES2022 */:
|
|
117314
117289
|
case 6 /* ES2020 */:
|
|
117315
117290
|
case 5 /* ES2015 */:
|
|
117316
|
-
case
|
|
117317
|
-
|
|
117318
|
-
case 1 /* CommonJS */:
|
|
117319
|
-
return transformImpliedNodeFormatDependentModule;
|
|
117291
|
+
case 200 /* Preserve */:
|
|
117292
|
+
return transformECMAScriptModule;
|
|
117320
117293
|
case 4 /* System */:
|
|
117321
117294
|
return transformSystemModule;
|
|
117295
|
+
case 100 /* Node16 */:
|
|
117296
|
+
case 199 /* NodeNext */:
|
|
117297
|
+
return transformNodeModule;
|
|
117322
117298
|
default:
|
|
117323
117299
|
return transformModule;
|
|
117324
117300
|
}
|
|
@@ -118048,7 +118024,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
118048
118024
|
newLine: compilerOptions.newLine,
|
|
118049
118025
|
noEmitHelpers: compilerOptions.noEmitHelpers,
|
|
118050
118026
|
module: getEmitModuleKind(compilerOptions),
|
|
118051
|
-
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
|
118052
118027
|
target: getEmitScriptTarget(compilerOptions),
|
|
118053
118028
|
sourceMap: compilerOptions.sourceMap,
|
|
118054
118029
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -118111,7 +118086,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
118111
118086
|
newLine: compilerOptions.newLine,
|
|
118112
118087
|
noEmitHelpers: true,
|
|
118113
118088
|
module: compilerOptions.module,
|
|
118114
|
-
moduleResolution: compilerOptions.moduleResolution,
|
|
118115
118089
|
target: compilerOptions.target,
|
|
118116
118090
|
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
|
118117
118091
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -123625,6 +123599,7 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
|
|
|
123625
123599
|
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
|
123626
123600
|
}
|
|
123627
123601
|
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
123602
|
+
var _a;
|
|
123628
123603
|
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
|
123629
123604
|
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
|
123630
123605
|
if (isTypeOnly) {
|
|
@@ -123640,28 +123615,19 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
|
123640
123615
|
return override;
|
|
123641
123616
|
}
|
|
123642
123617
|
}
|
|
123643
|
-
if (compilerOptions &&
|
|
123644
|
-
return
|
|
123618
|
+
if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
|
123619
|
+
return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
|
|
123620
|
+
usage.parent,
|
|
123621
|
+
/*requireStringLiteralLikeArgument*/
|
|
123622
|
+
false
|
|
123623
|
+
) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
123645
123624
|
}
|
|
123646
|
-
|
|
123647
|
-
|
|
123648
|
-
|
|
123649
|
-
if (!compilerOptions) {
|
|
123650
|
-
return void 0;
|
|
123625
|
+
if (file.impliedNodeFormat === void 0) return void 0;
|
|
123626
|
+
if (file.impliedNodeFormat !== 99 /* ESNext */) {
|
|
123627
|
+
return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
123651
123628
|
}
|
|
123652
123629
|
const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
|
|
123653
|
-
|
|
123654
|
-
usage.parent,
|
|
123655
|
-
/*requireStringLiteralLikeArgument*/
|
|
123656
|
-
false
|
|
123657
|
-
)) {
|
|
123658
|
-
return 1 /* CommonJS */;
|
|
123659
|
-
}
|
|
123660
|
-
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
|
123661
|
-
return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
123662
|
-
}
|
|
123663
|
-
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
|
123664
|
-
return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
|
|
123630
|
+
return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
123665
123631
|
}
|
|
123666
123632
|
function getResolutionModeOverride(node, grammarErrorOnNode) {
|
|
123667
123633
|
if (!node) return void 0;
|
|
@@ -123718,7 +123684,7 @@ function getTypeReferenceResolutionName(entry) {
|
|
|
123718
123684
|
}
|
|
123719
123685
|
var typeReferenceResolutionNameAndModeGetter = {
|
|
123720
123686
|
getName: getTypeReferenceResolutionName,
|
|
123721
|
-
getMode: (entry, file
|
|
123687
|
+
getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
|
|
123722
123688
|
};
|
|
123723
123689
|
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
123724
123690
|
return {
|
|
@@ -123892,7 +123858,13 @@ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, optio
|
|
|
123892
123858
|
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
123893
123859
|
}
|
|
123894
123860
|
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
123895
|
-
|
|
123861
|
+
switch (getEmitModuleResolutionKind(options)) {
|
|
123862
|
+
case 3 /* Node16 */:
|
|
123863
|
+
case 99 /* NodeNext */:
|
|
123864
|
+
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;
|
|
123865
|
+
default:
|
|
123866
|
+
return void 0;
|
|
123867
|
+
}
|
|
123896
123868
|
function lookupFromPackageJson() {
|
|
123897
123869
|
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
123898
123870
|
const packageJsonLocations = [];
|
|
@@ -124351,7 +124323,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124351
124323
|
isSourceFileFromExternalLibrary,
|
|
124352
124324
|
isSourceFileDefaultLibrary,
|
|
124353
124325
|
getModeForUsageLocation: getModeForUsageLocation2,
|
|
124354
|
-
getEmitSyntaxForUsageLocation,
|
|
124355
124326
|
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
124356
124327
|
getSourceFileFromReference,
|
|
124357
124328
|
getLibFileFromReference,
|
|
@@ -124380,11 +124351,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124380
124351
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
124381
124352
|
isSourceOfProjectReferenceRedirect,
|
|
124382
124353
|
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
124383
|
-
getCompilerOptionsForFile,
|
|
124384
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
124385
|
-
getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
|
|
124386
|
-
getImpliedNodeFormatForEmit: getImpliedNodeFormatForEmit2,
|
|
124387
|
-
shouldTransformImportCall,
|
|
124388
124354
|
emitBuildInfo,
|
|
124389
124355
|
fileExists,
|
|
124390
124356
|
readFile,
|
|
@@ -124967,10 +124933,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124967
124933
|
getSymlinkCache,
|
|
124968
124934
|
writeFile: writeFileCallback || writeFile2,
|
|
124969
124935
|
isEmitBlocked,
|
|
124970
|
-
shouldTransformImportCall,
|
|
124971
|
-
getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
|
|
124972
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
124973
|
-
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
124974
124936
|
readFile: (f) => host.readFile(f),
|
|
124975
124937
|
fileExists: (f) => {
|
|
124976
124938
|
const path = toPath3(f);
|
|
@@ -126020,14 +125982,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126020
125982
|
const resolvedTypeReferenceDirective = resolutions[index];
|
|
126021
125983
|
const fileName = ref.fileName;
|
|
126022
125984
|
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
|
126023
|
-
const mode = ref.resolutionMode ||
|
|
125985
|
+
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
126024
125986
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
|
126025
125987
|
}
|
|
126026
125988
|
}
|
|
126027
|
-
function getCompilerOptionsForFile(file) {
|
|
126028
|
-
var _a2;
|
|
126029
|
-
return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
126030
|
-
}
|
|
126031
125989
|
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
126032
125990
|
var _a2, _b2;
|
|
126033
125991
|
(_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 });
|
|
@@ -126128,12 +126086,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126128
126086
|
return host.getCanonicalFileName(fileName);
|
|
126129
126087
|
}
|
|
126130
126088
|
function processImportedModules(file) {
|
|
126089
|
+
var _a2;
|
|
126131
126090
|
collectExternalModuleReferences(file);
|
|
126132
126091
|
if (file.imports.length || file.moduleAugmentations.length) {
|
|
126133
126092
|
const moduleNames = getModuleNames(file);
|
|
126134
126093
|
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
126135
126094
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
126136
|
-
const optionsForFile =
|
|
126095
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
126137
126096
|
const resolutionsInFile = createModeAwareCache();
|
|
126138
126097
|
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
126139
126098
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
@@ -126689,7 +126648,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126689
126648
|
redirectInfo = cachedChain.redirectInfo;
|
|
126690
126649
|
} else {
|
|
126691
126650
|
reasons == null ? void 0 : reasons.forEach(processReason);
|
|
126692
|
-
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file
|
|
126651
|
+
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
|
126693
126652
|
}
|
|
126694
126653
|
if (fileProcessingReason) processReason(fileProcessingReason);
|
|
126695
126654
|
const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
|
|
@@ -127047,53 +127006,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
127047
127006
|
return symlinks;
|
|
127048
127007
|
}
|
|
127049
127008
|
function getModeForUsageLocation2(file, usage) {
|
|
127050
|
-
|
|
127051
|
-
|
|
127052
|
-
|
|
127053
|
-
return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
|
127009
|
+
var _a2;
|
|
127010
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
127011
|
+
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
|
127054
127012
|
}
|
|
127055
127013
|
function getModeForResolutionAtIndex2(file, index) {
|
|
127056
127014
|
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
|
127057
127015
|
}
|
|
127058
|
-
function getDefaultResolutionModeForFile2(sourceFile) {
|
|
127059
|
-
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127060
|
-
}
|
|
127061
|
-
function getImpliedNodeFormatForEmit2(sourceFile) {
|
|
127062
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127063
|
-
}
|
|
127064
|
-
function getEmitModuleFormatOfFile2(sourceFile) {
|
|
127065
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127066
|
-
}
|
|
127067
|
-
function shouldTransformImportCall(sourceFile) {
|
|
127068
|
-
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127069
|
-
}
|
|
127070
|
-
}
|
|
127071
|
-
function shouldTransformImportCallWorker(sourceFile, options) {
|
|
127072
|
-
const moduleKind = getEmitModuleKind(options);
|
|
127073
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
|
|
127074
|
-
return false;
|
|
127075
|
-
}
|
|
127076
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
|
|
127077
|
-
}
|
|
127078
|
-
function getEmitModuleFormatOfFileWorker(sourceFile, options) {
|
|
127079
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
|
127080
|
-
}
|
|
127081
|
-
function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
|
|
127082
|
-
var _a, _b;
|
|
127083
|
-
const moduleKind = getEmitModuleKind(options);
|
|
127084
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
127085
|
-
return sourceFile.impliedNodeFormat;
|
|
127086
|
-
}
|
|
127087
|
-
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
|
|
127088
|
-
return 1 /* CommonJS */;
|
|
127089
|
-
}
|
|
127090
|
-
if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
|
|
127091
|
-
return 99 /* ESNext */;
|
|
127092
|
-
}
|
|
127093
|
-
return void 0;
|
|
127094
|
-
}
|
|
127095
|
-
function getDefaultResolutionModeForFileWorker(sourceFile, options) {
|
|
127096
|
-
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
|
|
127097
127016
|
}
|
|
127098
127017
|
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
|
127099
127018
|
let setOfDeclarationDirectories;
|
|
@@ -130318,10 +130237,10 @@ function explainFiles(program, write) {
|
|
|
130318
130237
|
for (const file of program.getSourceFiles()) {
|
|
130319
130238
|
write(`${toFileName(file, relativeFileName)}`);
|
|
130320
130239
|
(_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
|
130321
|
-
(_b = explainIfFileIsRedirectAndImpliedFormat(file,
|
|
130240
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
|
130322
130241
|
}
|
|
130323
130242
|
}
|
|
130324
|
-
function explainIfFileIsRedirectAndImpliedFormat(file,
|
|
130243
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
130325
130244
|
var _a;
|
|
130326
130245
|
let result;
|
|
130327
130246
|
if (file.path !== file.resolvedPath) {
|
|
@@ -130341,7 +130260,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConverto
|
|
|
130341
130260
|
));
|
|
130342
130261
|
}
|
|
130343
130262
|
if (isExternalOrCommonJsModule(file)) {
|
|
130344
|
-
switch (
|
|
130263
|
+
switch (file.impliedNodeFormat) {
|
|
130345
130264
|
case 99 /* ESNext */:
|
|
130346
130265
|
if (file.packageJsonScope) {
|
|
130347
130266
|
(result ?? (result = [])).push(chainDiagnosticMessages(
|
|
@@ -136959,9 +136878,6 @@ function isTypeKeywordToken(node) {
|
|
|
136959
136878
|
function isTypeKeywordTokenOrIdentifier(node) {
|
|
136960
136879
|
return isTypeKeywordToken(node) || isIdentifier(node) && node.text === "type";
|
|
136961
136880
|
}
|
|
136962
|
-
function isExternalModuleSymbol(moduleSymbol) {
|
|
136963
|
-
return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */;
|
|
136964
|
-
}
|
|
136965
136881
|
function nodeSeenTracker() {
|
|
136966
136882
|
const seen = [];
|
|
136967
136883
|
return (node) => {
|
|
@@ -137012,9 +136928,7 @@ function createModuleSpecifierResolutionHost(program, host) {
|
|
|
137012
136928
|
isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
|
|
137013
136929
|
getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
|
|
137014
136930
|
getFileIncludeReasons: () => program.getFileIncludeReasons(),
|
|
137015
|
-
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
137016
|
-
getDefaultResolutionModeForFile: (file) => program.getDefaultResolutionModeForFile(file),
|
|
137017
|
-
getModeForResolutionAtIndex: (file, index) => program.getModeForResolutionAtIndex(file, index)
|
|
136931
|
+
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
137018
136932
|
};
|
|
137019
136933
|
}
|
|
137020
136934
|
function getModuleSpecifierResolverHost(program, host) {
|
|
@@ -138320,13 +138234,9 @@ function fileShouldUseJavaScriptRequire(file, program, host, preferRequire) {
|
|
|
138320
138234
|
if (!hasJSFileExtension(fileName)) {
|
|
138321
138235
|
return false;
|
|
138322
138236
|
}
|
|
138323
|
-
const compilerOptions =
|
|
138237
|
+
const compilerOptions = program.getCompilerOptions();
|
|
138324
138238
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
138325
|
-
const
|
|
138326
|
-
fileName: file,
|
|
138327
|
-
impliedNodeFormat: getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), host, compilerOptions)
|
|
138328
|
-
} : file;
|
|
138329
|
-
const impliedNodeFormat = getImpliedNodeFormatForEmitWorker(sourceFileLike, compilerOptions);
|
|
138239
|
+
const impliedNodeFormat = typeof file === "string" ? getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), host, compilerOptions) : file.impliedNodeFormat;
|
|
138330
138240
|
if (impliedNodeFormat === 99 /* ESNext */) {
|
|
138331
138241
|
return false;
|
|
138332
138242
|
}
|
|
@@ -141306,7 +141216,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
141306
141216
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
141307
141217
|
const diags = [];
|
|
141308
141218
|
const checker = program.getTypeChecker();
|
|
141309
|
-
const isCommonJSFile =
|
|
141219
|
+
const isCommonJSFile = sourceFile.impliedNodeFormat === 1 /* CommonJS */ || fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
|
|
141310
141220
|
if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (programContainsEsModules(program) || compilerOptionsIndicateEsModules(program.getCompilerOptions())) && containsTopLevelCommonjs(sourceFile)) {
|
|
141311
141221
|
diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
|
|
141312
141222
|
}
|
|
@@ -141548,8 +141458,9 @@ interface Symbol {
|
|
|
141548
141458
|
readonly [Symbol.toStringTag]: string;
|
|
141549
141459
|
}`;
|
|
141550
141460
|
var barebonesLibName = "lib.d.ts";
|
|
141551
|
-
var barebonesLibSourceFile
|
|
141461
|
+
var barebonesLibSourceFile;
|
|
141552
141462
|
function transpileWorker(input, transpileOptions, declaration) {
|
|
141463
|
+
barebonesLibSourceFile ?? (barebonesLibSourceFile = createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: 99 /* Latest */ }));
|
|
141553
141464
|
const diagnostics = [];
|
|
141554
141465
|
const options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};
|
|
141555
141466
|
const defaultOptions = getDefaultCompilerOptions2();
|
|
@@ -144019,7 +143930,7 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
144019
143930
|
const unusedImportsFromOldFile = /* @__PURE__ */ new Set();
|
|
144020
143931
|
for (const statement of toMove) {
|
|
144021
143932
|
forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
|
|
144022
|
-
if (!symbol.declarations) {
|
|
143933
|
+
if (!symbol.declarations || isGlobalType(checker, symbol)) {
|
|
144023
143934
|
return;
|
|
144024
143935
|
}
|
|
144025
143936
|
if (existingTargetLocals.has(skipAlias(symbol, checker))) {
|
|
@@ -144069,6 +143980,16 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
144069
143980
|
return !!jsxNamespaceSymbol2 && some(jsxNamespaceSymbol2.declarations, isInImport) ? jsxNamespaceSymbol2 : void 0;
|
|
144070
143981
|
}
|
|
144071
143982
|
}
|
|
143983
|
+
function isGlobalType(checker, symbol) {
|
|
143984
|
+
return !!checker.resolveName(
|
|
143985
|
+
symbol.name,
|
|
143986
|
+
/*location*/
|
|
143987
|
+
void 0,
|
|
143988
|
+
788968 /* Type */,
|
|
143989
|
+
/*excludeGlobals*/
|
|
143990
|
+
false
|
|
143991
|
+
);
|
|
143992
|
+
}
|
|
144072
143993
|
function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
|
|
144073
143994
|
let newFilename = proposedFilename;
|
|
144074
143995
|
for (let i = 1; ; i++) {
|
|
@@ -154302,7 +154223,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
154302
154223
|
compilerOptions,
|
|
154303
154224
|
createModuleSpecifierResolutionHost(program, host)
|
|
154304
154225
|
);
|
|
154305
|
-
const importKind = getImportKind(futureExportingSourceFile, exportKind,
|
|
154226
|
+
const importKind = getImportKind(futureExportingSourceFile, exportKind, compilerOptions);
|
|
154306
154227
|
const addAsTypeOnly = getAddAsTypeOnly(
|
|
154307
154228
|
isImportUsageValidAsTypeOnly,
|
|
154308
154229
|
/*isForNewImportDeclaration*/
|
|
@@ -154642,7 +154563,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
154642
154563
|
}
|
|
154643
154564
|
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
|
154644
154565
|
const packageJsonImportFilter = createPackageJsonImportFilter(importingFile, preferences, host);
|
|
154645
|
-
const importMap = createExistingImportMap(importingFile, program);
|
|
154566
|
+
const importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
|
154646
154567
|
return { getModuleSpecifierForBestExportInfo };
|
|
154647
154568
|
function getModuleSpecifierForBestExportInfo(exportInfo, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
|
154648
154569
|
const { fixes, computedWithoutCacheCount } = getImportFixes(
|
|
@@ -154745,7 +154666,7 @@ function getSingleExportInfoForSymbol(symbol, symbolName2, moduleSymbol, program
|
|
|
154745
154666
|
}
|
|
154746
154667
|
}
|
|
154747
154668
|
}
|
|
154748
|
-
function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = isFullSourceFile(sourceFile) ? createExistingImportMap(sourceFile, program) : void 0, fromCacheOnly) {
|
|
154669
|
+
function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = isFullSourceFile(sourceFile) ? createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()) : void 0, fromCacheOnly) {
|
|
154749
154670
|
const checker = program.getTypeChecker();
|
|
154750
154671
|
const existingImports = importMap ? flatMap(exportInfos, importMap.getImportsForExportInfo) : emptyArray;
|
|
154751
154672
|
const useNamespace = usagePosition !== void 0 && tryUseExistingNamespaceImport(existingImports, usagePosition);
|
|
@@ -154860,8 +154781,7 @@ function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker
|
|
|
154860
154781
|
};
|
|
154861
154782
|
}
|
|
154862
154783
|
}
|
|
154863
|
-
function createExistingImportMap(importingFile,
|
|
154864
|
-
const checker = program.getTypeChecker();
|
|
154784
|
+
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
|
154865
154785
|
let importMap;
|
|
154866
154786
|
for (const moduleSpecifier of importingFile.imports) {
|
|
154867
154787
|
const i = importFromModuleSpecifier(moduleSpecifier);
|
|
@@ -154882,7 +154802,7 @@ function createExistingImportMap(importingFile, program) {
|
|
|
154882
154802
|
const matchingDeclarations = importMap == null ? void 0 : importMap.get(getSymbolId(moduleSymbol));
|
|
154883
154803
|
if (!matchingDeclarations) return emptyArray;
|
|
154884
154804
|
if (isSourceFileJS(importingFile) && !(targetFlags & 111551 /* Value */) && !every(matchingDeclarations, isJSDocImportTag)) return emptyArray;
|
|
154885
|
-
const importKind = getImportKind(importingFile, exportKind,
|
|
154805
|
+
const importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
154886
154806
|
return matchingDeclarations.map((declaration) => ({ declaration, importKind, symbol, targetFlags }));
|
|
154887
154807
|
}
|
|
154888
154808
|
};
|
|
@@ -154897,8 +154817,8 @@ function shouldUseRequire(sourceFile, program) {
|
|
|
154897
154817
|
if (compilerOptions.configFile) {
|
|
154898
154818
|
return getEmitModuleKind(compilerOptions) < 5 /* ES2015 */;
|
|
154899
154819
|
}
|
|
154900
|
-
if (
|
|
154901
|
-
if (
|
|
154820
|
+
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */) return true;
|
|
154821
|
+
if (sourceFile.impliedNodeFormat === 99 /* ESNext */) return false;
|
|
154902
154822
|
for (const otherFile of program.getSourceFiles()) {
|
|
154903
154823
|
if (otherFile === sourceFile || !isSourceFileJS(otherFile) || program.isSourceFileFromExternalLibrary(otherFile)) continue;
|
|
154904
154824
|
if (otherFile.commonJsModuleIndicator && !otherFile.externalModuleIndicator) return true;
|
|
@@ -154950,7 +154870,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
|
|
|
154950
154870
|
if (!importedSymbolHasValueMeaning && isJs && usagePosition !== void 0) {
|
|
154951
154871
|
return { kind: 1 /* JsdocTypeImport */, moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo: exportInfo2, isReExport: i > 0 };
|
|
154952
154872
|
}
|
|
154953
|
-
const importKind = getImportKind(sourceFile, exportInfo2.exportKind,
|
|
154873
|
+
const importKind = getImportKind(sourceFile, exportInfo2.exportKind, compilerOptions);
|
|
154954
154874
|
let qualification;
|
|
154955
154875
|
if (usagePosition !== void 0 && importKind === 3 /* CommonJS */ && exportInfo2.exportKind === 0 /* Named */) {
|
|
154956
154876
|
const exportEquals = checker.resolveExternalModuleSymbol(exportInfo2.moduleSymbol);
|
|
@@ -155136,8 +155056,8 @@ function getUmdSymbol(token, checker) {
|
|
|
155136
155056
|
}
|
|
155137
155057
|
return void 0;
|
|
155138
155058
|
}
|
|
155139
|
-
function getImportKind(importingFile, exportKind,
|
|
155140
|
-
if (
|
|
155059
|
+
function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) {
|
|
155060
|
+
if (compilerOptions.verbatimModuleSyntax && (getEmitModuleKind(compilerOptions) === 1 /* CommonJS */ || importingFile.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
155141
155061
|
return 3 /* CommonJS */;
|
|
155142
155062
|
}
|
|
155143
155063
|
switch (exportKind) {
|
|
@@ -155146,18 +155066,18 @@ function getImportKind(importingFile, exportKind, program, forceImportKeyword) {
|
|
|
155146
155066
|
case 1 /* Default */:
|
|
155147
155067
|
return 1 /* Default */;
|
|
155148
155068
|
case 2 /* ExportEquals */:
|
|
155149
|
-
return getExportEqualsImportKind(importingFile,
|
|
155069
|
+
return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword);
|
|
155150
155070
|
case 3 /* UMD */:
|
|
155151
|
-
return getUmdImportKind(importingFile,
|
|
155071
|
+
return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword);
|
|
155152
155072
|
default:
|
|
155153
155073
|
return Debug.assertNever(exportKind);
|
|
155154
155074
|
}
|
|
155155
155075
|
}
|
|
155156
|
-
function getUmdImportKind(importingFile,
|
|
155157
|
-
if (getAllowSyntheticDefaultImports(
|
|
155076
|
+
function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
|
|
155077
|
+
if (getAllowSyntheticDefaultImports(compilerOptions)) {
|
|
155158
155078
|
return 1 /* Default */;
|
|
155159
155079
|
}
|
|
155160
|
-
const moduleKind = getEmitModuleKind(
|
|
155080
|
+
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
155161
155081
|
switch (moduleKind) {
|
|
155162
155082
|
case 2 /* AMD */:
|
|
155163
155083
|
case 1 /* CommonJS */:
|
|
@@ -155176,7 +155096,7 @@ function getUmdImportKind(importingFile, program, forceImportKeyword) {
|
|
|
155176
155096
|
return 2 /* Namespace */;
|
|
155177
155097
|
case 100 /* Node16 */:
|
|
155178
155098
|
case 199 /* NodeNext */:
|
|
155179
|
-
return
|
|
155099
|
+
return importingFile.impliedNodeFormat === 99 /* ESNext */ ? 2 /* Namespace */ : 3 /* CommonJS */;
|
|
155180
155100
|
default:
|
|
155181
155101
|
return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`);
|
|
155182
155102
|
}
|
|
@@ -155660,12 +155580,6 @@ function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) {
|
|
|
155660
155580
|
function symbolFlagsHaveMeaning(flags, meaning) {
|
|
155661
155581
|
return meaning === 7 /* All */ ? true : meaning & 1 /* Value */ ? !!(flags & 111551 /* Value */) : meaning & 2 /* Type */ ? !!(flags & 788968 /* Type */) : meaning & 4 /* Namespace */ ? !!(flags & 1920 /* Namespace */) : false;
|
|
155662
155582
|
}
|
|
155663
|
-
function getImpliedNodeFormatForEmit(file, program) {
|
|
155664
|
-
return isFullSourceFile(file) ? program.getImpliedNodeFormatForEmit(file) : getImpliedNodeFormatForEmitWorker(file, program.getCompilerOptions());
|
|
155665
|
-
}
|
|
155666
|
-
function getEmitModuleFormatOfFile(file, program) {
|
|
155667
|
-
return isFullSourceFile(file) ? program.getEmitModuleFormatOfFile(file) : getEmitModuleFormatOfFileWorker(file, program.getCompilerOptions());
|
|
155668
|
-
}
|
|
155669
155583
|
|
|
155670
155584
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
155671
155585
|
var fixId17 = "addMissingConstraint";
|
|
@@ -162938,12 +162852,10 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
|
|
|
162938
162852
|
const printer = isSnippet ? createSnippetPrinter({
|
|
162939
162853
|
removeComments: true,
|
|
162940
162854
|
module: options.module,
|
|
162941
|
-
moduleResolution: options.moduleResolution,
|
|
162942
162855
|
target: options.target
|
|
162943
162856
|
}) : createPrinter({
|
|
162944
162857
|
removeComments: true,
|
|
162945
162858
|
module: options.module,
|
|
162946
|
-
moduleResolution: options.moduleResolution,
|
|
162947
162859
|
target: options.target
|
|
162948
162860
|
});
|
|
162949
162861
|
setEmitFlags(typeNode, 1 /* SingleLine */);
|
|
@@ -163199,7 +163111,6 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
|
|
|
163199
163111
|
const printer = createSnippetPrinter({
|
|
163200
163112
|
removeComments: true,
|
|
163201
163113
|
module: options.module,
|
|
163202
|
-
moduleResolution: options.moduleResolution,
|
|
163203
163114
|
target: options.target,
|
|
163204
163115
|
newLine: getNewLineKind(newLineChar)
|
|
163205
163116
|
});
|
|
@@ -163386,7 +163297,7 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
163386
163297
|
if (originIsResolvedExport(origin)) {
|
|
163387
163298
|
sourceDisplay = [textPart(origin.moduleSpecifier)];
|
|
163388
163299
|
if (importStatementCompletion) {
|
|
163389
|
-
({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile,
|
|
163300
|
+
({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences));
|
|
163390
163301
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : void 0;
|
|
163391
163302
|
}
|
|
163392
163303
|
}
|
|
@@ -163502,7 +163413,6 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
|
|
|
163502
163413
|
const printer = createSnippetPrinter({
|
|
163503
163414
|
removeComments: true,
|
|
163504
163415
|
module: options.module,
|
|
163505
|
-
moduleResolution: options.moduleResolution,
|
|
163506
163416
|
target: options.target,
|
|
163507
163417
|
omitTrailingSemicolon: false,
|
|
163508
163418
|
newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
|
|
@@ -163653,7 +163563,6 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
|
|
|
163653
163563
|
const printer = createSnippetPrinter({
|
|
163654
163564
|
removeComments: true,
|
|
163655
163565
|
module: options.module,
|
|
163656
|
-
moduleResolution: options.moduleResolution,
|
|
163657
163566
|
target: options.target,
|
|
163658
163567
|
omitTrailingSemicolon: false,
|
|
163659
163568
|
newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
|
|
@@ -163674,7 +163583,6 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
|
|
|
163674
163583
|
const signaturePrinter = createPrinter({
|
|
163675
163584
|
removeComments: true,
|
|
163676
163585
|
module: options.module,
|
|
163677
|
-
moduleResolution: options.moduleResolution,
|
|
163678
163586
|
target: options.target,
|
|
163679
163587
|
omitTrailingSemicolon: true
|
|
163680
163588
|
});
|
|
@@ -163936,7 +163844,7 @@ function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbo
|
|
|
163936
163844
|
};
|
|
163937
163845
|
return unresolvedOrigin;
|
|
163938
163846
|
}
|
|
163939
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile,
|
|
163847
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
|
|
163940
163848
|
const replacementSpan = importStatementCompletion.replacementSpan;
|
|
163941
163849
|
const quotedModuleSpecifier = escapeSnippetText(quote(sourceFile, preferences, origin.moduleSpecifier));
|
|
163942
163850
|
const exportKind = origin.isDefaultExport ? 1 /* Default */ : origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */;
|
|
@@ -163944,7 +163852,7 @@ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatemen
|
|
|
163944
163852
|
const importKind = ts_codefix_exports.getImportKind(
|
|
163945
163853
|
sourceFile,
|
|
163946
163854
|
exportKind,
|
|
163947
|
-
|
|
163855
|
+
options,
|
|
163948
163856
|
/*forceImportKeyword*/
|
|
163949
163857
|
true
|
|
163950
163858
|
);
|
|
@@ -166320,7 +166228,7 @@ function createNameAndKindSet() {
|
|
|
166320
166228
|
}
|
|
166321
166229
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences, includeSymbol) {
|
|
166322
166230
|
if (isInReferenceComment(sourceFile, position)) {
|
|
166323
|
-
const entries = getTripleSlashReferenceCompletion(sourceFile, position,
|
|
166231
|
+
const entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
166324
166232
|
return entries && convertPathCompletions(entries);
|
|
166325
166233
|
}
|
|
166326
166234
|
if (isInString(sourceFile, position, contextToken)) {
|
|
@@ -166628,7 +166536,7 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, prog
|
|
|
166628
166536
|
const compilerOptions = program.getCompilerOptions();
|
|
166629
166537
|
const typeChecker = program.getTypeChecker();
|
|
166630
166538
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
|
166631
|
-
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory,
|
|
166539
|
+
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, extensionOptions, typeChecker);
|
|
166632
166540
|
}
|
|
166633
166541
|
function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile, typeChecker, preferences, resolutionMode) {
|
|
166634
166542
|
return {
|
|
@@ -166639,15 +166547,14 @@ function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile
|
|
|
166639
166547
|
resolutionMode
|
|
166640
166548
|
};
|
|
166641
166549
|
}
|
|
166642
|
-
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory,
|
|
166643
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166550
|
+
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) {
|
|
166644
166551
|
if (compilerOptions.rootDirs) {
|
|
166645
166552
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(
|
|
166646
166553
|
compilerOptions.rootDirs,
|
|
166647
166554
|
literalValue,
|
|
166648
166555
|
scriptDirectory,
|
|
166649
166556
|
extensionOptions,
|
|
166650
|
-
|
|
166557
|
+
compilerOptions,
|
|
166651
166558
|
host,
|
|
166652
166559
|
scriptPath
|
|
166653
166560
|
);
|
|
@@ -166656,7 +166563,6 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
|
166656
166563
|
literalValue,
|
|
166657
166564
|
scriptDirectory,
|
|
166658
166565
|
extensionOptions,
|
|
166659
|
-
program,
|
|
166660
166566
|
host,
|
|
166661
166567
|
/*moduleSpecifierIsRelative*/
|
|
166662
166568
|
true,
|
|
@@ -166683,8 +166589,7 @@ function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ign
|
|
|
166683
166589
|
compareStringsCaseSensitive
|
|
166684
166590
|
);
|
|
166685
166591
|
}
|
|
166686
|
-
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions,
|
|
166687
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166592
|
+
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) {
|
|
166688
166593
|
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
|
166689
166594
|
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
|
166690
166595
|
const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
|
@@ -166693,7 +166598,6 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
166693
166598
|
fragment,
|
|
166694
166599
|
baseDirectory,
|
|
166695
166600
|
extensionOptions,
|
|
166696
|
-
program,
|
|
166697
166601
|
host,
|
|
166698
166602
|
/*moduleSpecifierIsRelative*/
|
|
166699
166603
|
true,
|
|
@@ -166702,7 +166606,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
166702
166606
|
(itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
|
|
166703
166607
|
);
|
|
166704
166608
|
}
|
|
166705
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions,
|
|
166609
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
|
166706
166610
|
var _a;
|
|
166707
166611
|
if (fragment === void 0) {
|
|
166708
166612
|
fragment = "";
|
|
@@ -166727,7 +166631,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166727
166631
|
if (versionPaths) {
|
|
166728
166632
|
const packageDirectory = getDirectoryPath(packageJsonPath);
|
|
166729
166633
|
const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
|
|
166730
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions,
|
|
166634
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
|
|
166731
166635
|
return result;
|
|
166732
166636
|
}
|
|
166733
166637
|
}
|
|
@@ -166753,7 +166657,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166753
166657
|
}
|
|
166754
166658
|
const { name, extension } = getFilenameWithExtensionOption(
|
|
166755
166659
|
getBaseFileName(filePath),
|
|
166756
|
-
|
|
166660
|
+
host.getCompilationSettings(),
|
|
166757
166661
|
extensionOptions,
|
|
166758
166662
|
/*isExportsWildcard*/
|
|
166759
166663
|
false
|
|
@@ -166772,7 +166676,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166772
166676
|
}
|
|
166773
166677
|
return result;
|
|
166774
166678
|
}
|
|
166775
|
-
function getFilenameWithExtensionOption(name,
|
|
166679
|
+
function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions, isExportsWildcard) {
|
|
166776
166680
|
const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
|
|
166777
166681
|
if (nonJsResult) {
|
|
166778
166682
|
return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
|
|
@@ -166782,8 +166686,7 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
166782
166686
|
}
|
|
166783
166687
|
let allowedEndings = getModuleSpecifierPreferences(
|
|
166784
166688
|
{ importModuleSpecifierEnding: extensionOptions.endingPreference },
|
|
166785
|
-
|
|
166786
|
-
program.getCompilerOptions(),
|
|
166689
|
+
compilerOptions,
|
|
166787
166690
|
extensionOptions.importingSourceFile
|
|
166788
166691
|
).getAllowedEndingsInPreferredOrder(extensionOptions.resolutionMode);
|
|
166789
166692
|
if (isExportsWildcard) {
|
|
@@ -166793,16 +166696,16 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
166793
166696
|
if (fileExtensionIsOneOf(name, supportedTSImplementationExtensions)) {
|
|
166794
166697
|
return { name, extension: tryGetExtensionFromPath2(name) };
|
|
166795
166698
|
}
|
|
166796
|
-
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name,
|
|
166699
|
+
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
|
|
166797
166700
|
return outputExtension2 ? { name: changeExtension(name, outputExtension2), extension: outputExtension2 } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
166798
166701
|
}
|
|
166799
166702
|
if (!isExportsWildcard && (allowedEndings[0] === 0 /* Minimal */ || allowedEndings[0] === 1 /* Index */) && fileExtensionIsOneOf(name, [".js" /* Js */, ".jsx" /* Jsx */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */])) {
|
|
166800
166703
|
return { name: removeFileExtension(name), extension: tryGetExtensionFromPath2(name) };
|
|
166801
166704
|
}
|
|
166802
|
-
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name,
|
|
166705
|
+
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
|
|
166803
166706
|
return outputExtension ? { name: changeExtension(name, outputExtension), extension: outputExtension } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
166804
166707
|
}
|
|
166805
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions,
|
|
166708
|
+
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
|
|
166806
166709
|
const getPatternsForKey = (key) => paths[key];
|
|
166807
166710
|
const comparePaths2 = (a, b) => {
|
|
166808
166711
|
const patternA = tryParsePattern(a);
|
|
@@ -166818,14 +166721,13 @@ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensio
|
|
|
166818
166721
|
fragment,
|
|
166819
166722
|
baseDirectory,
|
|
166820
166723
|
extensionOptions,
|
|
166821
|
-
program,
|
|
166822
166724
|
host,
|
|
166823
166725
|
getOwnKeys(paths),
|
|
166824
166726
|
getPatternsForKey,
|
|
166825
166727
|
comparePaths2
|
|
166826
166728
|
);
|
|
166827
166729
|
}
|
|
166828
|
-
function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions,
|
|
166730
|
+
function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths2) {
|
|
166829
166731
|
let pathResults = [];
|
|
166830
166732
|
let matchedPath;
|
|
166831
166733
|
for (const key of keys) {
|
|
@@ -166844,7 +166746,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
|
166844
166746
|
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(key, matchedPath) !== 1 /* GreaterThan */) {
|
|
166845
166747
|
pathResults.push({
|
|
166846
166748
|
matchedPattern: isMatch,
|
|
166847
|
-
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports && isMatch,
|
|
166749
|
+
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports && isMatch, host).map(({ name, kind, extension }) => nameAndKind(name, kind, extension))
|
|
166848
166750
|
});
|
|
166849
166751
|
}
|
|
166850
166752
|
}
|
|
@@ -166852,9 +166754,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
|
166852
166754
|
pathResults.forEach((pathResult) => pathResult.results.forEach((r) => result.add(r)));
|
|
166853
166755
|
return matchedPath !== void 0;
|
|
166854
166756
|
}
|
|
166855
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode,
|
|
166856
|
-
const typeChecker = program.getTypeChecker();
|
|
166857
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166757
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, extensionOptions, typeChecker) {
|
|
166858
166758
|
const { baseUrl, paths } = compilerOptions;
|
|
166859
166759
|
const result = createNameAndKindSet();
|
|
166860
166760
|
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
@@ -166864,7 +166764,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166864
166764
|
fragment,
|
|
166865
166765
|
absolute,
|
|
166866
166766
|
extensionOptions,
|
|
166867
|
-
program,
|
|
166868
166767
|
host,
|
|
166869
166768
|
/*moduleSpecifierIsRelative*/
|
|
166870
166769
|
false,
|
|
@@ -166875,7 +166774,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166875
166774
|
}
|
|
166876
166775
|
if (paths) {
|
|
166877
166776
|
const absolute = getPathsBasePath(compilerOptions, host);
|
|
166878
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions,
|
|
166777
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
|
|
166879
166778
|
}
|
|
166880
166779
|
const fragmentDirectory = getFragmentDirectory(fragment);
|
|
166881
166780
|
for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
|
|
@@ -166886,7 +166785,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166886
166785
|
void 0
|
|
166887
166786
|
));
|
|
166888
166787
|
}
|
|
166889
|
-
getCompletionEntriesFromTypings(host,
|
|
166788
|
+
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
166890
166789
|
if (moduleResolutionUsesNodeModules(moduleResolution)) {
|
|
166891
166790
|
let foundGlobal = false;
|
|
166892
166791
|
if (fragmentDirectory === void 0) {
|
|
@@ -166911,7 +166810,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166911
166810
|
fragment,
|
|
166912
166811
|
nodeModules,
|
|
166913
166812
|
extensionOptions,
|
|
166914
|
-
program,
|
|
166915
166813
|
host,
|
|
166916
166814
|
/*moduleSpecifierIsRelative*/
|
|
166917
166815
|
false,
|
|
@@ -166956,7 +166854,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166956
166854
|
fragmentSubpath,
|
|
166957
166855
|
packageDirectory,
|
|
166958
166856
|
extensionOptions,
|
|
166959
|
-
program,
|
|
166960
166857
|
host,
|
|
166961
166858
|
keys,
|
|
166962
166859
|
(key) => singleElementArray(getPatternFromFirstMatchingCondition(exports2[key], conditions)),
|
|
@@ -166989,7 +166886,7 @@ function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
|
166989
166886
|
function getFragmentDirectory(fragment) {
|
|
166990
166887
|
return containsSlash(fragment) ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
|
166991
166888
|
}
|
|
166992
|
-
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard,
|
|
166889
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard, host) {
|
|
166993
166890
|
if (!endsWith(path, "*")) {
|
|
166994
166891
|
return !path.includes("*") ? justPathMappingName(path, "script" /* scriptElement */) : emptyArray;
|
|
166995
166892
|
}
|
|
@@ -166999,15 +166896,15 @@ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory
|
|
|
166999
166896
|
const starIsFullPathComponent = path[path.length - 2] === "/";
|
|
167000
166897
|
return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : flatMap(patterns, (pattern) => {
|
|
167001
166898
|
var _a;
|
|
167002
|
-
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExportsWildcard,
|
|
166899
|
+
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExportsWildcard, host)) == null ? void 0 : _a.map(({ name, ...rest }) => ({ name: pathPrefix + name, ...rest }));
|
|
167003
166900
|
});
|
|
167004
166901
|
}
|
|
167005
|
-
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard,
|
|
166902
|
+
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host));
|
|
167006
166903
|
function justPathMappingName(name, kind) {
|
|
167007
166904
|
return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: void 0 }] : emptyArray;
|
|
167008
166905
|
}
|
|
167009
166906
|
}
|
|
167010
|
-
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard,
|
|
166907
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host) {
|
|
167011
166908
|
if (!host.readDirectory) {
|
|
167012
166909
|
return void 0;
|
|
167013
166910
|
}
|
|
@@ -167040,7 +166937,7 @@ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensio
|
|
|
167040
166937
|
if (containsSlash(trimmedWithPattern)) {
|
|
167041
166938
|
return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
|
167042
166939
|
}
|
|
167043
|
-
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern,
|
|
166940
|
+
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions, isExportsWildcard);
|
|
167044
166941
|
return nameAndKind(name, "script" /* scriptElement */, extension);
|
|
167045
166942
|
}
|
|
167046
166943
|
});
|
|
@@ -167068,8 +166965,7 @@ function getAmbientModuleCompletions(fragment, fragmentDirectory, checker) {
|
|
|
167068
166965
|
}
|
|
167069
166966
|
return nonRelativeModuleNames;
|
|
167070
166967
|
}
|
|
167071
|
-
function getTripleSlashReferenceCompletion(sourceFile, position,
|
|
167072
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166968
|
+
function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) {
|
|
167073
166969
|
const token = getTokenAtPosition(sourceFile, position);
|
|
167074
166970
|
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
|
167075
166971
|
const range = commentRanges && find(commentRanges, (commentRange) => position >= commentRange.pos && position <= commentRange.end);
|
|
@@ -167087,16 +166983,14 @@ function getTripleSlashReferenceCompletion(sourceFile, position, program, host)
|
|
|
167087
166983
|
toComplete,
|
|
167088
166984
|
scriptPath,
|
|
167089
166985
|
getExtensionOptions(compilerOptions, 0 /* Filename */, sourceFile),
|
|
167090
|
-
program,
|
|
167091
166986
|
host,
|
|
167092
166987
|
/*moduleSpecifierIsRelative*/
|
|
167093
166988
|
true,
|
|
167094
166989
|
sourceFile.path
|
|
167095
|
-
) : kind === "types" ? getCompletionEntriesFromTypings(host,
|
|
166990
|
+
) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
|
|
167096
166991
|
return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
|
|
167097
166992
|
}
|
|
167098
|
-
function getCompletionEntriesFromTypings(host,
|
|
167099
|
-
const options = program.getCompilerOptions();
|
|
166993
|
+
function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
|
|
167100
166994
|
const seen = /* @__PURE__ */ new Map();
|
|
167101
166995
|
const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
|
|
167102
166996
|
for (const root of typeRoots) {
|
|
@@ -167130,7 +167024,6 @@ function getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDire
|
|
|
167130
167024
|
remainingFragment,
|
|
167131
167025
|
baseDirectory,
|
|
167132
167026
|
extensionOptions,
|
|
167133
|
-
program,
|
|
167134
167027
|
host,
|
|
167135
167028
|
/*moduleSpecifierIsRelative*/
|
|
167136
167029
|
false,
|
|
@@ -178479,7 +178372,6 @@ __export(ts_exports2, {
|
|
|
178479
178372
|
canHaveJSDoc: () => canHaveJSDoc,
|
|
178480
178373
|
canHaveLocals: () => canHaveLocals,
|
|
178481
178374
|
canHaveModifiers: () => canHaveModifiers,
|
|
178482
|
-
canHaveModuleSpecifier: () => canHaveModuleSpecifier,
|
|
178483
178375
|
canHaveSymbol: () => canHaveSymbol,
|
|
178484
178376
|
canIncludeBindAndCheckDiagnsotics: () => canIncludeBindAndCheckDiagnsotics,
|
|
178485
178377
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
@@ -178957,7 +178849,6 @@ __export(ts_exports2, {
|
|
|
178957
178849
|
getDefaultLibFilePath: () => getDefaultLibFilePath,
|
|
178958
178850
|
getDefaultLikeExportInfo: () => getDefaultLikeExportInfo,
|
|
178959
178851
|
getDefaultLikeExportNameFromDeclaration: () => getDefaultLikeExportNameFromDeclaration,
|
|
178960
|
-
getDefaultResolutionModeForFileWorker: () => getDefaultResolutionModeForFileWorker,
|
|
178961
178852
|
getDiagnosticText: () => getDiagnosticText,
|
|
178962
178853
|
getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
|
|
178963
178854
|
getDirectoryPath: () => getDirectoryPath,
|
|
@@ -178988,7 +178879,6 @@ __export(ts_exports2, {
|
|
|
178988
178879
|
getEmitFlags: () => getEmitFlags,
|
|
178989
178880
|
getEmitHelpers: () => getEmitHelpers,
|
|
178990
178881
|
getEmitModuleDetectionKind: () => getEmitModuleDetectionKind,
|
|
178991
|
-
getEmitModuleFormatOfFileWorker: () => getEmitModuleFormatOfFileWorker,
|
|
178992
178882
|
getEmitModuleKind: () => getEmitModuleKind,
|
|
178993
178883
|
getEmitModuleResolutionKind: () => getEmitModuleResolutionKind,
|
|
178994
178884
|
getEmitScriptTarget: () => getEmitScriptTarget,
|
|
@@ -179039,7 +178929,6 @@ __export(ts_exports2, {
|
|
|
179039
178929
|
getIdentifierGeneratedImportReference: () => getIdentifierGeneratedImportReference,
|
|
179040
178930
|
getIdentifierTypeArguments: () => getIdentifierTypeArguments,
|
|
179041
178931
|
getImmediatelyInvokedFunctionExpression: () => getImmediatelyInvokedFunctionExpression,
|
|
179042
|
-
getImpliedNodeFormatForEmitWorker: () => getImpliedNodeFormatForEmitWorker,
|
|
179043
178932
|
getImpliedNodeFormatForFile: () => getImpliedNodeFormatForFile,
|
|
179044
178933
|
getImpliedNodeFormatForFileWorker: () => getImpliedNodeFormatForFileWorker,
|
|
179045
178934
|
getImportNeedsImportDefaultHelper: () => getImportNeedsImportDefaultHelper,
|
|
@@ -179399,7 +179288,6 @@ __export(ts_exports2, {
|
|
|
179399
179288
|
importDefaultHelper: () => importDefaultHelper,
|
|
179400
179289
|
importFromModuleSpecifier: () => importFromModuleSpecifier,
|
|
179401
179290
|
importStarHelper: () => importStarHelper,
|
|
179402
|
-
importSyntaxAffectsModuleResolution: () => importSyntaxAffectsModuleResolution,
|
|
179403
179291
|
indexOfAnyCharCode: () => indexOfAnyCharCode,
|
|
179404
179292
|
indexOfNode: () => indexOfNode,
|
|
179405
179293
|
indicesOf: () => indicesOf,
|
|
@@ -180494,11 +180382,11 @@ __export(ts_exports2, {
|
|
|
180494
180382
|
transformESDecorators: () => transformESDecorators,
|
|
180495
180383
|
transformESNext: () => transformESNext,
|
|
180496
180384
|
transformGenerators: () => transformGenerators,
|
|
180497
|
-
transformImpliedNodeFormatDependentModule: () => transformImpliedNodeFormatDependentModule,
|
|
180498
180385
|
transformJsx: () => transformJsx,
|
|
180499
180386
|
transformLegacyDecorators: () => transformLegacyDecorators,
|
|
180500
180387
|
transformModule: () => transformModule,
|
|
180501
180388
|
transformNamedEvaluation: () => transformNamedEvaluation,
|
|
180389
|
+
transformNodeModule: () => transformNodeModule,
|
|
180502
180390
|
transformNodes: () => transformNodes,
|
|
180503
180391
|
transformSystemModule: () => transformSystemModule,
|
|
180504
180392
|
transformTypeScript: () => transformTypeScript,
|
|
@@ -183869,8 +183757,11 @@ var Project3 = class _Project {
|
|
|
183869
183757
|
const originalText = Debug.checkDefined(rootSourceFile.getText());
|
|
183870
183758
|
(_b = this.getScriptInfo(rootFile)) == null ? void 0 : _b.editContent(0, originalText.length, updatedText);
|
|
183871
183759
|
this.updateGraph();
|
|
183872
|
-
|
|
183873
|
-
|
|
183760
|
+
try {
|
|
183761
|
+
cb(this.program, originalProgram, (_c = this.program) == null ? void 0 : _c.getSourceFile(rootFile));
|
|
183762
|
+
} finally {
|
|
183763
|
+
(_d = this.getScriptInfo(rootFile)) == null ? void 0 : _d.editContent(0, this.program.getSourceFile(rootFile).getText().length, originalText);
|
|
183764
|
+
}
|
|
183874
183765
|
}
|
|
183875
183766
|
/** @internal */
|
|
183876
183767
|
getCompilerOptionsForNoDtsResolutionProject() {
|
|
@@ -192911,7 +192802,6 @@ if (typeof console !== "undefined") {
|
|
|
192911
192802
|
canHaveJSDoc,
|
|
192912
192803
|
canHaveLocals,
|
|
192913
192804
|
canHaveModifiers,
|
|
192914
|
-
canHaveModuleSpecifier,
|
|
192915
192805
|
canHaveSymbol,
|
|
192916
192806
|
canIncludeBindAndCheckDiagnsotics,
|
|
192917
192807
|
canJsonReportNoInputFiles,
|
|
@@ -193389,7 +193279,6 @@ if (typeof console !== "undefined") {
|
|
|
193389
193279
|
getDefaultLibFilePath,
|
|
193390
193280
|
getDefaultLikeExportInfo,
|
|
193391
193281
|
getDefaultLikeExportNameFromDeclaration,
|
|
193392
|
-
getDefaultResolutionModeForFileWorker,
|
|
193393
193282
|
getDiagnosticText,
|
|
193394
193283
|
getDiagnosticsWithinSpan,
|
|
193395
193284
|
getDirectoryPath,
|
|
@@ -193420,7 +193309,6 @@ if (typeof console !== "undefined") {
|
|
|
193420
193309
|
getEmitFlags,
|
|
193421
193310
|
getEmitHelpers,
|
|
193422
193311
|
getEmitModuleDetectionKind,
|
|
193423
|
-
getEmitModuleFormatOfFileWorker,
|
|
193424
193312
|
getEmitModuleKind,
|
|
193425
193313
|
getEmitModuleResolutionKind,
|
|
193426
193314
|
getEmitScriptTarget,
|
|
@@ -193471,7 +193359,6 @@ if (typeof console !== "undefined") {
|
|
|
193471
193359
|
getIdentifierGeneratedImportReference,
|
|
193472
193360
|
getIdentifierTypeArguments,
|
|
193473
193361
|
getImmediatelyInvokedFunctionExpression,
|
|
193474
|
-
getImpliedNodeFormatForEmitWorker,
|
|
193475
193362
|
getImpliedNodeFormatForFile,
|
|
193476
193363
|
getImpliedNodeFormatForFileWorker,
|
|
193477
193364
|
getImportNeedsImportDefaultHelper,
|
|
@@ -193831,7 +193718,6 @@ if (typeof console !== "undefined") {
|
|
|
193831
193718
|
importDefaultHelper,
|
|
193832
193719
|
importFromModuleSpecifier,
|
|
193833
193720
|
importStarHelper,
|
|
193834
|
-
importSyntaxAffectsModuleResolution,
|
|
193835
193721
|
indexOfAnyCharCode,
|
|
193836
193722
|
indexOfNode,
|
|
193837
193723
|
indicesOf,
|
|
@@ -194926,11 +194812,11 @@ if (typeof console !== "undefined") {
|
|
|
194926
194812
|
transformESDecorators,
|
|
194927
194813
|
transformESNext,
|
|
194928
194814
|
transformGenerators,
|
|
194929
|
-
transformImpliedNodeFormatDependentModule,
|
|
194930
194815
|
transformJsx,
|
|
194931
194816
|
transformLegacyDecorators,
|
|
194932
194817
|
transformModule,
|
|
194933
194818
|
transformNamedEvaluation,
|
|
194819
|
+
transformNodeModule,
|
|
194934
194820
|
transformNodes,
|
|
194935
194821
|
transformSystemModule,
|
|
194936
194822
|
transformTypeScript,
|
|
@@ -195020,6 +194906,5 @@ if (typeof console !== "undefined") {
|
|
|
195020
194906
|
writeFileEnsuringDirectories,
|
|
195021
194907
|
zipWith
|
|
195022
194908
|
});
|
|
195023
|
-
})(typeof module !== "undefined" && module.exports
|
|
195024
|
-
if (typeof module !== "undefined" && module.exports) { ts = module.exports; }
|
|
194909
|
+
})({ get exports() { return ts; }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v; } } })
|
|
195025
194910
|
//# sourceMappingURL=typescript.js.map
|