typescript 5.5.0-dev.20240603 → 5.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +204 -252
- package/lib/typescript.d.ts +22 -89
- package/lib/typescript.js +284 -371
- package/package.json +2 -2
package/lib/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 =
|
|
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);
|
|
@@ -56313,10 +56275,11 @@ function createTypeChecker(host) {
|
|
|
56313
56275
|
return result ? setTextRange2(context, result, node) : void 0;
|
|
56314
56276
|
}
|
|
56315
56277
|
function createRecoveryBoundary() {
|
|
56278
|
+
let trackedSymbols;
|
|
56316
56279
|
let unreportedErrors;
|
|
56317
56280
|
const oldTracker = context.tracker;
|
|
56318
56281
|
const oldTrackedSymbols = context.trackedSymbols;
|
|
56319
|
-
context.trackedSymbols =
|
|
56282
|
+
context.trackedSymbols = void 0;
|
|
56320
56283
|
const oldEncounteredError = context.encounteredError;
|
|
56321
56284
|
context.tracker = new SymbolTrackerImpl(context, {
|
|
56322
56285
|
...oldTracker.inner,
|
|
@@ -56336,17 +56299,7 @@ function createTypeChecker(host) {
|
|
|
56336
56299
|
markError(() => oldTracker.reportNonSerializableProperty(name));
|
|
56337
56300
|
},
|
|
56338
56301
|
trackSymbol(sym, decl, meaning) {
|
|
56339
|
-
|
|
56340
|
-
sym,
|
|
56341
|
-
decl,
|
|
56342
|
-
meaning,
|
|
56343
|
-
/*shouldComputeAliasesToMakeVisible*/
|
|
56344
|
-
false
|
|
56345
|
-
);
|
|
56346
|
-
if (accessibility.accessibility !== 0 /* Accessible */) {
|
|
56347
|
-
(context.trackedSymbols ?? (context.trackedSymbols = [])).push([sym, decl, meaning]);
|
|
56348
|
-
return true;
|
|
56349
|
-
}
|
|
56302
|
+
(trackedSymbols ?? (trackedSymbols = [])).push([sym, decl, meaning]);
|
|
56350
56303
|
return false;
|
|
56351
56304
|
},
|
|
56352
56305
|
moduleResolverHost: context.tracker.moduleResolverHost
|
|
@@ -56360,13 +56313,12 @@ function createTypeChecker(host) {
|
|
|
56360
56313
|
(unreportedErrors ?? (unreportedErrors = [])).push(unreportedError);
|
|
56361
56314
|
}
|
|
56362
56315
|
function startRecoveryScope2() {
|
|
56363
|
-
|
|
56364
|
-
const initialTrackedSymbolsTop = ((_a = context.trackedSymbols) == null ? void 0 : _a.length) ?? 0;
|
|
56316
|
+
const trackedSymbolsTop = (trackedSymbols == null ? void 0 : trackedSymbols.length) ?? 0;
|
|
56365
56317
|
const unreportedErrorsTop = (unreportedErrors == null ? void 0 : unreportedErrors.length) ?? 0;
|
|
56366
56318
|
return () => {
|
|
56367
56319
|
hadError = false;
|
|
56368
|
-
if (
|
|
56369
|
-
|
|
56320
|
+
if (trackedSymbols) {
|
|
56321
|
+
trackedSymbols.length = trackedSymbolsTop;
|
|
56370
56322
|
}
|
|
56371
56323
|
if (unreportedErrors) {
|
|
56372
56324
|
unreportedErrors.length = unreportedErrorsTop;
|
|
@@ -56375,14 +56327,13 @@ function createTypeChecker(host) {
|
|
|
56375
56327
|
}
|
|
56376
56328
|
function finalizeBoundary2() {
|
|
56377
56329
|
context.tracker = oldTracker;
|
|
56378
|
-
const newTrackedSymbols = context.trackedSymbols;
|
|
56379
56330
|
context.trackedSymbols = oldTrackedSymbols;
|
|
56380
56331
|
context.encounteredError = oldEncounteredError;
|
|
56381
56332
|
unreportedErrors == null ? void 0 : unreportedErrors.forEach((fn) => fn());
|
|
56382
56333
|
if (hadError) {
|
|
56383
56334
|
return false;
|
|
56384
56335
|
}
|
|
56385
|
-
|
|
56336
|
+
trackedSymbols == null ? void 0 : trackedSymbols.forEach(
|
|
56386
56337
|
([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
|
|
56387
56338
|
symbol,
|
|
56388
56339
|
enclosingDeclaration,
|
|
@@ -56395,6 +56346,57 @@ function createTypeChecker(host) {
|
|
|
56395
56346
|
function onEnterNewScope(node) {
|
|
56396
56347
|
return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
|
|
56397
56348
|
}
|
|
56349
|
+
function tryVisitSimpleTypeNode(node) {
|
|
56350
|
+
const innerNode = skipTypeParentheses(node);
|
|
56351
|
+
switch (innerNode.kind) {
|
|
56352
|
+
case 183 /* TypeReference */:
|
|
56353
|
+
return tryVisitTypeReference(innerNode);
|
|
56354
|
+
case 186 /* TypeQuery */:
|
|
56355
|
+
return tryVisitTypeQuery(innerNode);
|
|
56356
|
+
case 199 /* IndexedAccessType */:
|
|
56357
|
+
return tryVisitIndexedAccess(innerNode);
|
|
56358
|
+
case 198 /* TypeOperator */:
|
|
56359
|
+
const typeOperatorNode = innerNode;
|
|
56360
|
+
if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
|
|
56361
|
+
return tryVisitKeyOf(typeOperatorNode);
|
|
56362
|
+
}
|
|
56363
|
+
}
|
|
56364
|
+
return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
|
|
56365
|
+
}
|
|
56366
|
+
function tryVisitIndexedAccess(node) {
|
|
56367
|
+
const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
|
|
56368
|
+
if (resultObjectType === void 0) {
|
|
56369
|
+
return void 0;
|
|
56370
|
+
}
|
|
56371
|
+
return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
|
|
56372
|
+
}
|
|
56373
|
+
function tryVisitKeyOf(node) {
|
|
56374
|
+
Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
|
|
56375
|
+
const type = tryVisitSimpleTypeNode(node.type);
|
|
56376
|
+
if (type === void 0) {
|
|
56377
|
+
return void 0;
|
|
56378
|
+
}
|
|
56379
|
+
return factory.updateTypeOperatorNode(node, type);
|
|
56380
|
+
}
|
|
56381
|
+
function tryVisitTypeQuery(node) {
|
|
56382
|
+
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
|
|
56383
|
+
if (!introducesError) {
|
|
56384
|
+
return factory.updateTypeQueryNode(
|
|
56385
|
+
node,
|
|
56386
|
+
exprName,
|
|
56387
|
+
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
56388
|
+
);
|
|
56389
|
+
}
|
|
56390
|
+
const serializedName = serializeTypeName(
|
|
56391
|
+
context,
|
|
56392
|
+
node.exprName,
|
|
56393
|
+
/*isTypeOf*/
|
|
56394
|
+
true
|
|
56395
|
+
);
|
|
56396
|
+
if (serializedName) {
|
|
56397
|
+
return setTextRange2(context, serializedName, node.exprName);
|
|
56398
|
+
}
|
|
56399
|
+
}
|
|
56398
56400
|
function tryVisitTypeReference(node) {
|
|
56399
56401
|
if (canReuseTypeNode(context, node)) {
|
|
56400
56402
|
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
|
|
@@ -56444,7 +56446,7 @@ function createTypeChecker(host) {
|
|
|
56444
56446
|
}
|
|
56445
56447
|
if (isJSDocTypeLiteral(node)) {
|
|
56446
56448
|
return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
|
|
56447
|
-
const name = isIdentifier(t.name) ? t.name : t.name.right;
|
|
56449
|
+
const name = visitNode(isIdentifier(t.name) ? t.name : t.name.right, visitExistingNodeTreeSymbols, isIdentifier);
|
|
56448
56450
|
const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
|
|
56449
56451
|
const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
|
|
56450
56452
|
return factory.createPropertySignature(
|
|
@@ -56488,7 +56490,7 @@ function createTypeChecker(host) {
|
|
|
56488
56490
|
void 0,
|
|
56489
56491
|
getEffectiveDotDotDotForParameter(p),
|
|
56490
56492
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56491
|
-
p.questionToken,
|
|
56493
|
+
factory.cloneNode(p.questionToken),
|
|
56492
56494
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56493
56495
|
/*initializer*/
|
|
56494
56496
|
void 0
|
|
@@ -56503,7 +56505,7 @@ function createTypeChecker(host) {
|
|
|
56503
56505
|
void 0,
|
|
56504
56506
|
getEffectiveDotDotDotForParameter(p),
|
|
56505
56507
|
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56506
|
-
p.questionToken,
|
|
56508
|
+
factory.cloneNode(p.questionToken),
|
|
56507
56509
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56508
56510
|
/*initializer*/
|
|
56509
56511
|
void 0
|
|
@@ -56522,19 +56524,19 @@ function createTypeChecker(host) {
|
|
|
56522
56524
|
if (isTypeParameterDeclaration(node)) {
|
|
56523
56525
|
return factory.updateTypeParameterDeclaration(
|
|
56524
56526
|
node,
|
|
56525
|
-
node.modifiers,
|
|
56527
|
+
visitNodes2(node.modifiers, visitExistingNodeTreeSymbols, isModifier),
|
|
56526
56528
|
setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
|
|
56527
56529
|
visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56528
56530
|
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
|
|
56529
56531
|
);
|
|
56530
56532
|
}
|
|
56531
|
-
if (isIndexedAccessTypeNode(node)
|
|
56532
|
-
const
|
|
56533
|
-
if (!
|
|
56533
|
+
if (isIndexedAccessTypeNode(node)) {
|
|
56534
|
+
const result = tryVisitIndexedAccess(node);
|
|
56535
|
+
if (!result) {
|
|
56534
56536
|
hadError = true;
|
|
56535
56537
|
return node;
|
|
56536
56538
|
}
|
|
56537
|
-
return
|
|
56539
|
+
return result;
|
|
56538
56540
|
}
|
|
56539
56541
|
if (isTypeReferenceNode(node)) {
|
|
56540
56542
|
const result = tryVisitTypeReference(node);
|
|
@@ -56554,8 +56556,8 @@ function createTypeChecker(host) {
|
|
|
56554
56556
|
return factory.updateImportTypeNode(
|
|
56555
56557
|
node,
|
|
56556
56558
|
factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)),
|
|
56557
|
-
node.attributes,
|
|
56558
|
-
node.qualifier,
|
|
56559
|
+
visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
|
|
56560
|
+
visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
|
|
56559
56561
|
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56560
56562
|
node.isTypeOf
|
|
56561
56563
|
);
|
|
@@ -56577,25 +56579,12 @@ function createTypeChecker(host) {
|
|
|
56577
56579
|
return visited;
|
|
56578
56580
|
}
|
|
56579
56581
|
if (isTypeQueryNode(node)) {
|
|
56580
|
-
const
|
|
56581
|
-
if (
|
|
56582
|
-
const serializedName = serializeTypeName(
|
|
56583
|
-
context,
|
|
56584
|
-
node.exprName,
|
|
56585
|
-
/*isTypeOf*/
|
|
56586
|
-
true
|
|
56587
|
-
);
|
|
56588
|
-
if (serializedName) {
|
|
56589
|
-
return setTextRange2(context, serializedName, node.exprName);
|
|
56590
|
-
}
|
|
56582
|
+
const result = tryVisitTypeQuery(node);
|
|
56583
|
+
if (!result) {
|
|
56591
56584
|
hadError = true;
|
|
56592
56585
|
return node;
|
|
56593
56586
|
}
|
|
56594
|
-
return
|
|
56595
|
-
node,
|
|
56596
|
-
exprName,
|
|
56597
|
-
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
56598
|
-
);
|
|
56587
|
+
return result;
|
|
56599
56588
|
}
|
|
56600
56589
|
if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
|
|
56601
56590
|
const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
|
|
@@ -56604,8 +56593,28 @@ function createTypeChecker(host) {
|
|
|
56604
56593
|
} else {
|
|
56605
56594
|
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
|
56606
56595
|
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
|
56607
|
-
|
|
56608
|
-
|
|
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
|
+
}
|
|
56609
56618
|
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
|
56610
56619
|
return factory.createIdentifier(literal.text);
|
|
56611
56620
|
}
|
|
@@ -56622,9 +56631,9 @@ function createTypeChecker(host) {
|
|
|
56622
56631
|
hadError = hadError || introducesError;
|
|
56623
56632
|
parameterName = result;
|
|
56624
56633
|
} else {
|
|
56625
|
-
parameterName = node.parameterName;
|
|
56634
|
+
parameterName = factory.cloneNode(node.parameterName);
|
|
56626
56635
|
}
|
|
56627
|
-
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));
|
|
56628
56637
|
}
|
|
56629
56638
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
56630
56639
|
const visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
|
|
@@ -56660,14 +56669,12 @@ function createTypeChecker(host) {
|
|
|
56660
56669
|
return node;
|
|
56661
56670
|
}
|
|
56662
56671
|
} else if (node.operator === 143 /* KeyOfKeyword */) {
|
|
56663
|
-
|
|
56664
|
-
|
|
56665
|
-
|
|
56666
|
-
|
|
56667
|
-
return node;
|
|
56668
|
-
}
|
|
56669
|
-
return factory.updateTypeOperatorNode(node, type);
|
|
56672
|
+
const result = tryVisitKeyOf(node);
|
|
56673
|
+
if (!result) {
|
|
56674
|
+
hadError = true;
|
|
56675
|
+
return node;
|
|
56670
56676
|
}
|
|
56677
|
+
return result;
|
|
56671
56678
|
}
|
|
56672
56679
|
}
|
|
56673
56680
|
return visitEachChild2(node, visitExistingNodeTreeSymbols);
|
|
@@ -56717,7 +56724,7 @@ function createTypeChecker(host) {
|
|
|
56717
56724
|
/*yieldModuleSymbol*/
|
|
56718
56725
|
true
|
|
56719
56726
|
)[0];
|
|
56720
|
-
if (parentSymbol && parentSymbol
|
|
56727
|
+
if (parentSymbol && isExternalModuleSymbol(parentSymbol)) {
|
|
56721
56728
|
name = getSpecifierForModuleSymbol(parentSymbol, context);
|
|
56722
56729
|
} else {
|
|
56723
56730
|
const targetFile = getExternalModuleFileFromDeclaration(parent2);
|
|
@@ -80101,7 +80108,7 @@ function createTypeChecker(host) {
|
|
|
80101
80108
|
return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
|
|
80102
80109
|
}
|
|
80103
80110
|
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
80104
|
-
const hasDefaultOnly =
|
|
80111
|
+
const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
80105
80112
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
80106
80113
|
const synthType = type;
|
|
80107
80114
|
if (!synthType.defaultOnlyType) {
|
|
@@ -85328,7 +85335,7 @@ function createTypeChecker(host) {
|
|
|
85328
85335
|
});
|
|
85329
85336
|
}
|
|
85330
85337
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
85331
|
-
if (
|
|
85338
|
+
if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
85332
85339
|
return;
|
|
85333
85340
|
}
|
|
85334
85341
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -86749,7 +86756,7 @@ function createTypeChecker(host) {
|
|
|
86749
86756
|
}
|
|
86750
86757
|
}
|
|
86751
86758
|
function checkClassNameCollisionWithObject(name) {
|
|
86752
|
-
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" &&
|
|
86759
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
86753
86760
|
error2(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
|
86754
86761
|
}
|
|
86755
86762
|
}
|
|
@@ -87830,7 +87837,7 @@ function createTypeChecker(host) {
|
|
|
87830
87837
|
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
|
87831
87838
|
}
|
|
87832
87839
|
}
|
|
87833
|
-
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 */)) {
|
|
87834
87841
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
|
87835
87842
|
if (exportModifier) {
|
|
87836
87843
|
error2(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
@@ -88040,10 +88047,8 @@ function createTypeChecker(host) {
|
|
|
88040
88047
|
}
|
|
88041
88048
|
}
|
|
88042
88049
|
}
|
|
88043
|
-
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 */)) {
|
|
88044
88051
|
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
88045
|
-
} else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
|
88046
|
-
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
|
|
88047
88052
|
}
|
|
88048
88053
|
}
|
|
88049
88054
|
if (isImportSpecifier(node)) {
|
|
@@ -88082,7 +88087,7 @@ function createTypeChecker(host) {
|
|
|
88082
88087
|
function checkImportBinding(node) {
|
|
88083
88088
|
checkCollisionsForDeclarationName(node, node.name);
|
|
88084
88089
|
checkAliasSymbol(node);
|
|
88085
|
-
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 */)) {
|
|
88086
88091
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
88087
88092
|
}
|
|
88088
88093
|
}
|
|
@@ -88103,7 +88108,7 @@ function createTypeChecker(host) {
|
|
|
88103
88108
|
if (validForTypeAttributes && override) {
|
|
88104
88109
|
return;
|
|
88105
88110
|
}
|
|
88106
|
-
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier &&
|
|
88111
|
+
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
88107
88112
|
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
|
88108
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;
|
|
88109
88114
|
return grammarErrorOnNode(node, message);
|
|
@@ -88136,7 +88141,7 @@ function createTypeChecker(host) {
|
|
|
88136
88141
|
if (importClause.namedBindings) {
|
|
88137
88142
|
if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
|
|
88138
88143
|
checkImportBinding(importClause.namedBindings);
|
|
88139
|
-
if (
|
|
88144
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
|
|
88140
88145
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
88141
88146
|
}
|
|
88142
88147
|
} else {
|
|
@@ -88176,7 +88181,7 @@ function createTypeChecker(host) {
|
|
|
88176
88181
|
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
|
88177
88182
|
}
|
|
88178
88183
|
} else {
|
|
88179
|
-
if (5 /* ES2015 */
|
|
88184
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
88180
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);
|
|
88181
88186
|
}
|
|
88182
88187
|
}
|
|
@@ -88205,7 +88210,7 @@ function createTypeChecker(host) {
|
|
|
88205
88210
|
} else if (node.exportClause) {
|
|
88206
88211
|
checkAliasSymbol(node.exportClause);
|
|
88207
88212
|
}
|
|
88208
|
-
if (
|
|
88213
|
+
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
88209
88214
|
if (node.exportClause) {
|
|
88210
88215
|
if (getESModuleInterop(compilerOptions)) {
|
|
88211
88216
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
@@ -88258,7 +88263,7 @@ function createTypeChecker(host) {
|
|
|
88258
88263
|
markLinkedReferences(node, 7 /* ExportSpecifier */);
|
|
88259
88264
|
}
|
|
88260
88265
|
} else {
|
|
88261
|
-
if (getESModuleInterop(compilerOptions) &&
|
|
88266
|
+
if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && idText(node.propertyName || node.name) === "default") {
|
|
88262
88267
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
88263
88268
|
}
|
|
88264
88269
|
}
|
|
@@ -88284,7 +88289,7 @@ function createTypeChecker(host) {
|
|
|
88284
88289
|
if (typeAnnotationNode) {
|
|
88285
88290
|
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
|
|
88286
88291
|
}
|
|
88287
|
-
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 */);
|
|
88288
88293
|
if (node.expression.kind === 80 /* Identifier */) {
|
|
88289
88294
|
const id = node.expression;
|
|
88290
88295
|
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
|
@@ -88364,7 +88369,7 @@ function createTypeChecker(host) {
|
|
|
88364
88369
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
88365
88370
|
}
|
|
88366
88371
|
if (node.isExportEquals) {
|
|
88367
|
-
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 */)) {
|
|
88368
88373
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
88369
88374
|
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
|
88370
88375
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
@@ -90862,7 +90867,7 @@ function createTypeChecker(host) {
|
|
|
90862
90867
|
break;
|
|
90863
90868
|
case 95 /* ExportKeyword */:
|
|
90864
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
|
|
90865
|
-
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 */)) {
|
|
90866
90871
|
return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
90867
90872
|
}
|
|
90868
90873
|
if (flags & 32 /* Export */) {
|
|
@@ -91771,7 +91776,7 @@ function createTypeChecker(host) {
|
|
|
91771
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;
|
|
91772
91777
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
91773
91778
|
}
|
|
91774
|
-
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 */)) {
|
|
91775
91780
|
checkESModuleMarker(node.name);
|
|
91776
91781
|
}
|
|
91777
91782
|
return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
|
|
@@ -92272,9 +92277,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
|
|
|
92272
92277
|
isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
|
|
92273
92278
|
fileExists: (fileName) => host.fileExists(fileName),
|
|
92274
92279
|
getFileIncludeReasons: () => host.getFileIncludeReasons(),
|
|
92275
|
-
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
92276
|
-
getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
|
|
92277
|
-
getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
|
|
92280
|
+
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
|
92278
92281
|
};
|
|
92279
92282
|
}
|
|
92280
92283
|
var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
|
@@ -112121,7 +112124,7 @@ function transformModule(context) {
|
|
|
112121
112124
|
case 354 /* PartiallyEmittedExpression */:
|
|
112122
112125
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
112123
112126
|
case 213 /* CallExpression */:
|
|
112124
|
-
if (isImportCall(node) &&
|
|
112127
|
+
if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
|
|
112125
112128
|
return visitImportCallExpression(node);
|
|
112126
112129
|
}
|
|
112127
112130
|
break;
|
|
@@ -115116,8 +115119,8 @@ function transformECMAScriptModule(context) {
|
|
|
115116
115119
|
}
|
|
115117
115120
|
}
|
|
115118
115121
|
|
|
115119
|
-
// src/compiler/transformers/module/
|
|
115120
|
-
function
|
|
115122
|
+
// src/compiler/transformers/module/node.ts
|
|
115123
|
+
function transformNodeModule(context) {
|
|
115121
115124
|
const previousOnSubstituteNode = context.onSubstituteNode;
|
|
115122
115125
|
const previousOnEmitNode = context.onEmitNode;
|
|
115123
115126
|
const esmTransform = transformECMAScriptModule(context);
|
|
@@ -115128,7 +115131,6 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115128
115131
|
const cjsTransform = transformModule(context);
|
|
115129
115132
|
const cjsOnSubstituteNode = context.onSubstituteNode;
|
|
115130
115133
|
const cjsOnEmitNode = context.onEmitNode;
|
|
115131
|
-
const getEmitModuleFormatOfFile2 = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
|
115132
115134
|
context.onSubstituteNode = onSubstituteNode;
|
|
115133
115135
|
context.onEmitNode = onEmitNode;
|
|
115134
115136
|
context.enableSubstitution(307 /* SourceFile */);
|
|
@@ -115143,7 +115145,7 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115143
115145
|
if (!currentSourceFile) {
|
|
115144
115146
|
return previousOnSubstituteNode(hint, node);
|
|
115145
115147
|
}
|
|
115146
|
-
if (
|
|
115148
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
115147
115149
|
return esmOnSubstituteNode(hint, node);
|
|
115148
115150
|
}
|
|
115149
115151
|
return cjsOnSubstituteNode(hint, node);
|
|
@@ -115156,13 +115158,13 @@ function transformImpliedNodeFormatDependentModule(context) {
|
|
|
115156
115158
|
if (!currentSourceFile) {
|
|
115157
115159
|
return previousOnEmitNode(hint, node, emitCallback);
|
|
115158
115160
|
}
|
|
115159
|
-
if (
|
|
115161
|
+
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
|
115160
115162
|
return esmOnEmitNode(hint, node, emitCallback);
|
|
115161
115163
|
}
|
|
115162
115164
|
return cjsOnEmitNode(hint, node, emitCallback);
|
|
115163
115165
|
}
|
|
115164
115166
|
function getModuleTransformForFile(file) {
|
|
115165
|
-
return
|
|
115167
|
+
return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
|
|
115166
115168
|
}
|
|
115167
115169
|
function transformSourceFile(node) {
|
|
115168
115170
|
if (node.isDeclarationFile) {
|
|
@@ -117282,18 +117284,17 @@ function isProcessedComponent(node) {
|
|
|
117282
117284
|
// src/compiler/transformer.ts
|
|
117283
117285
|
function getModuleTransformer(moduleKind) {
|
|
117284
117286
|
switch (moduleKind) {
|
|
117285
|
-
case 200 /* Preserve */:
|
|
117286
|
-
return transformECMAScriptModule;
|
|
117287
117287
|
case 99 /* ESNext */:
|
|
117288
117288
|
case 7 /* ES2022 */:
|
|
117289
117289
|
case 6 /* ES2020 */:
|
|
117290
117290
|
case 5 /* ES2015 */:
|
|
117291
|
-
case
|
|
117292
|
-
|
|
117293
|
-
case 1 /* CommonJS */:
|
|
117294
|
-
return transformImpliedNodeFormatDependentModule;
|
|
117291
|
+
case 200 /* Preserve */:
|
|
117292
|
+
return transformECMAScriptModule;
|
|
117295
117293
|
case 4 /* System */:
|
|
117296
117294
|
return transformSystemModule;
|
|
117295
|
+
case 100 /* Node16 */:
|
|
117296
|
+
case 199 /* NodeNext */:
|
|
117297
|
+
return transformNodeModule;
|
|
117297
117298
|
default:
|
|
117298
117299
|
return transformModule;
|
|
117299
117300
|
}
|
|
@@ -118023,7 +118024,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
118023
118024
|
newLine: compilerOptions.newLine,
|
|
118024
118025
|
noEmitHelpers: compilerOptions.noEmitHelpers,
|
|
118025
118026
|
module: getEmitModuleKind(compilerOptions),
|
|
118026
|
-
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
|
118027
118027
|
target: getEmitScriptTarget(compilerOptions),
|
|
118028
118028
|
sourceMap: compilerOptions.sourceMap,
|
|
118029
118029
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -118086,7 +118086,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
118086
118086
|
newLine: compilerOptions.newLine,
|
|
118087
118087
|
noEmitHelpers: true,
|
|
118088
118088
|
module: compilerOptions.module,
|
|
118089
|
-
moduleResolution: compilerOptions.moduleResolution,
|
|
118090
118089
|
target: compilerOptions.target,
|
|
118091
118090
|
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
|
118092
118091
|
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
@@ -123600,6 +123599,7 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
|
|
|
123600
123599
|
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
|
123601
123600
|
}
|
|
123602
123601
|
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
123602
|
+
var _a;
|
|
123603
123603
|
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
|
123604
123604
|
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
|
123605
123605
|
if (isTypeOnly) {
|
|
@@ -123615,28 +123615,19 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
|
123615
123615
|
return override;
|
|
123616
123616
|
}
|
|
123617
123617
|
}
|
|
123618
|
-
if (compilerOptions &&
|
|
123619
|
-
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 */;
|
|
123620
123624
|
}
|
|
123621
|
-
|
|
123622
|
-
|
|
123623
|
-
|
|
123624
|
-
if (!compilerOptions) {
|
|
123625
|
-
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 */;
|
|
123626
123628
|
}
|
|
123627
123629
|
const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
|
|
123628
|
-
|
|
123629
|
-
usage.parent,
|
|
123630
|
-
/*requireStringLiteralLikeArgument*/
|
|
123631
|
-
false
|
|
123632
|
-
)) {
|
|
123633
|
-
return 1 /* CommonJS */;
|
|
123634
|
-
}
|
|
123635
|
-
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
|
123636
|
-
return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
123637
|
-
}
|
|
123638
|
-
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
|
123639
|
-
return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
|
|
123630
|
+
return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
123640
123631
|
}
|
|
123641
123632
|
function getResolutionModeOverride(node, grammarErrorOnNode) {
|
|
123642
123633
|
if (!node) return void 0;
|
|
@@ -123693,7 +123684,7 @@ function getTypeReferenceResolutionName(entry) {
|
|
|
123693
123684
|
}
|
|
123694
123685
|
var typeReferenceResolutionNameAndModeGetter = {
|
|
123695
123686
|
getName: getTypeReferenceResolutionName,
|
|
123696
|
-
getMode: (entry, file
|
|
123687
|
+
getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
|
|
123697
123688
|
};
|
|
123698
123689
|
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
123699
123690
|
return {
|
|
@@ -123867,7 +123858,13 @@ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, optio
|
|
|
123867
123858
|
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
123868
123859
|
}
|
|
123869
123860
|
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
123870
|
-
|
|
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
|
+
}
|
|
123871
123868
|
function lookupFromPackageJson() {
|
|
123872
123869
|
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
123873
123870
|
const packageJsonLocations = [];
|
|
@@ -124326,7 +124323,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124326
124323
|
isSourceFileFromExternalLibrary,
|
|
124327
124324
|
isSourceFileDefaultLibrary,
|
|
124328
124325
|
getModeForUsageLocation: getModeForUsageLocation2,
|
|
124329
|
-
getEmitSyntaxForUsageLocation,
|
|
124330
124326
|
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
124331
124327
|
getSourceFileFromReference,
|
|
124332
124328
|
getLibFileFromReference,
|
|
@@ -124355,11 +124351,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124355
124351
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
124356
124352
|
isSourceOfProjectReferenceRedirect,
|
|
124357
124353
|
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
124358
|
-
getCompilerOptionsForFile,
|
|
124359
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
124360
|
-
getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
|
|
124361
|
-
getImpliedNodeFormatForEmit: getImpliedNodeFormatForEmit2,
|
|
124362
|
-
shouldTransformImportCall,
|
|
124363
124354
|
emitBuildInfo,
|
|
124364
124355
|
fileExists,
|
|
124365
124356
|
readFile,
|
|
@@ -124942,10 +124933,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124942
124933
|
getSymlinkCache,
|
|
124943
124934
|
writeFile: writeFileCallback || writeFile2,
|
|
124944
124935
|
isEmitBlocked,
|
|
124945
|
-
shouldTransformImportCall,
|
|
124946
|
-
getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
|
|
124947
|
-
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
|
124948
|
-
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
124949
124936
|
readFile: (f) => host.readFile(f),
|
|
124950
124937
|
fileExists: (f) => {
|
|
124951
124938
|
const path = toPath3(f);
|
|
@@ -125995,14 +125982,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
125995
125982
|
const resolvedTypeReferenceDirective = resolutions[index];
|
|
125996
125983
|
const fileName = ref.fileName;
|
|
125997
125984
|
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
|
125998
|
-
const mode = ref.resolutionMode ||
|
|
125985
|
+
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
125999
125986
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
|
126000
125987
|
}
|
|
126001
125988
|
}
|
|
126002
|
-
function getCompilerOptionsForFile(file) {
|
|
126003
|
-
var _a2;
|
|
126004
|
-
return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
126005
|
-
}
|
|
126006
125989
|
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
126007
125990
|
var _a2, _b2;
|
|
126008
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 });
|
|
@@ -126103,12 +126086,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126103
126086
|
return host.getCanonicalFileName(fileName);
|
|
126104
126087
|
}
|
|
126105
126088
|
function processImportedModules(file) {
|
|
126089
|
+
var _a2;
|
|
126106
126090
|
collectExternalModuleReferences(file);
|
|
126107
126091
|
if (file.imports.length || file.moduleAugmentations.length) {
|
|
126108
126092
|
const moduleNames = getModuleNames(file);
|
|
126109
126093
|
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
126110
126094
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
126111
|
-
const optionsForFile =
|
|
126095
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
126112
126096
|
const resolutionsInFile = createModeAwareCache();
|
|
126113
126097
|
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
126114
126098
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
@@ -126531,7 +126515,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126531
126515
|
}
|
|
126532
126516
|
return Version.zero;
|
|
126533
126517
|
}
|
|
126534
|
-
function checkDeprecations(deprecatedIn, removedIn, createDiagnostic, fn) {
|
|
126518
|
+
function checkDeprecations(deprecatedIn, stopsWorkingIn, removedIn, createDiagnostic, fn) {
|
|
126535
126519
|
const deprecatedInVersion = new Version(deprecatedIn);
|
|
126536
126520
|
const removedInVersion = new Version(removedIn);
|
|
126537
126521
|
const typescriptVersion = new Version(typeScriptVersion3 || versionMajorMinor);
|
|
@@ -126548,9 +126532,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126548
126532
|
}
|
|
126549
126533
|
} else {
|
|
126550
126534
|
if (value === void 0) {
|
|
126551
|
-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name,
|
|
126535
|
+
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name, stopsWorkingIn, deprecatedIn);
|
|
126552
126536
|
} else {
|
|
126553
|
-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value,
|
|
126537
|
+
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value, stopsWorkingIn, deprecatedIn);
|
|
126554
126538
|
}
|
|
126555
126539
|
}
|
|
126556
126540
|
});
|
|
@@ -126586,7 +126570,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126586
126570
|
);
|
|
126587
126571
|
}
|
|
126588
126572
|
}
|
|
126589
|
-
checkDeprecations("5.0", "5.5", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
126573
|
+
checkDeprecations("5.0", "5.5", "6.0", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
126590
126574
|
if (options.target === 0 /* ES3 */) {
|
|
126591
126575
|
createDeprecatedDiagnostic("target", "ES3");
|
|
126592
126576
|
}
|
|
@@ -126638,7 +126622,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126638
126622
|
function createDiagnostic(_name, _value, _useInstead, message, ...args) {
|
|
126639
126623
|
createDiagnosticForReference(parentFile, index, message, ...args);
|
|
126640
126624
|
}
|
|
126641
|
-
checkDeprecations("5.0", "5.5", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
126625
|
+
checkDeprecations("5.0", "5.5", "6.0", createDiagnostic, (createDeprecatedDiagnostic) => {
|
|
126642
126626
|
if (ref.prepend) {
|
|
126643
126627
|
createDeprecatedDiagnostic("prepend");
|
|
126644
126628
|
}
|
|
@@ -126664,7 +126648,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
126664
126648
|
redirectInfo = cachedChain.redirectInfo;
|
|
126665
126649
|
} else {
|
|
126666
126650
|
reasons == null ? void 0 : reasons.forEach(processReason);
|
|
126667
|
-
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file
|
|
126651
|
+
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
|
126668
126652
|
}
|
|
126669
126653
|
if (fileProcessingReason) processReason(fileProcessingReason);
|
|
126670
126654
|
const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
|
|
@@ -127022,53 +127006,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
127022
127006
|
return symlinks;
|
|
127023
127007
|
}
|
|
127024
127008
|
function getModeForUsageLocation2(file, usage) {
|
|
127025
|
-
|
|
127026
|
-
|
|
127027
|
-
|
|
127028
|
-
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);
|
|
127029
127012
|
}
|
|
127030
127013
|
function getModeForResolutionAtIndex2(file, index) {
|
|
127031
127014
|
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
|
127032
127015
|
}
|
|
127033
|
-
function getDefaultResolutionModeForFile2(sourceFile) {
|
|
127034
|
-
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127035
|
-
}
|
|
127036
|
-
function getImpliedNodeFormatForEmit2(sourceFile) {
|
|
127037
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127038
|
-
}
|
|
127039
|
-
function getEmitModuleFormatOfFile2(sourceFile) {
|
|
127040
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127041
|
-
}
|
|
127042
|
-
function shouldTransformImportCall(sourceFile) {
|
|
127043
|
-
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
|
127044
|
-
}
|
|
127045
|
-
}
|
|
127046
|
-
function shouldTransformImportCallWorker(sourceFile, options) {
|
|
127047
|
-
const moduleKind = getEmitModuleKind(options);
|
|
127048
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
|
|
127049
|
-
return false;
|
|
127050
|
-
}
|
|
127051
|
-
return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
|
|
127052
|
-
}
|
|
127053
|
-
function getEmitModuleFormatOfFileWorker(sourceFile, options) {
|
|
127054
|
-
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
|
127055
|
-
}
|
|
127056
|
-
function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
|
|
127057
|
-
var _a, _b;
|
|
127058
|
-
const moduleKind = getEmitModuleKind(options);
|
|
127059
|
-
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
127060
|
-
return sourceFile.impliedNodeFormat;
|
|
127061
|
-
}
|
|
127062
|
-
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
|
|
127063
|
-
return 1 /* CommonJS */;
|
|
127064
|
-
}
|
|
127065
|
-
if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
|
|
127066
|
-
return 99 /* ESNext */;
|
|
127067
|
-
}
|
|
127068
|
-
return void 0;
|
|
127069
|
-
}
|
|
127070
|
-
function getDefaultResolutionModeForFileWorker(sourceFile, options) {
|
|
127071
|
-
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
|
|
127072
127016
|
}
|
|
127073
127017
|
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
|
127074
127018
|
let setOfDeclarationDirectories;
|
|
@@ -130293,10 +130237,10 @@ function explainFiles(program, write) {
|
|
|
130293
130237
|
for (const file of program.getSourceFiles()) {
|
|
130294
130238
|
write(`${toFileName(file, relativeFileName)}`);
|
|
130295
130239
|
(_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
|
130296
|
-
(_b = explainIfFileIsRedirectAndImpliedFormat(file,
|
|
130240
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
|
130297
130241
|
}
|
|
130298
130242
|
}
|
|
130299
|
-
function explainIfFileIsRedirectAndImpliedFormat(file,
|
|
130243
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
130300
130244
|
var _a;
|
|
130301
130245
|
let result;
|
|
130302
130246
|
if (file.path !== file.resolvedPath) {
|
|
@@ -130316,7 +130260,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConverto
|
|
|
130316
130260
|
));
|
|
130317
130261
|
}
|
|
130318
130262
|
if (isExternalOrCommonJsModule(file)) {
|
|
130319
|
-
switch (
|
|
130263
|
+
switch (file.impliedNodeFormat) {
|
|
130320
130264
|
case 99 /* ESNext */:
|
|
130321
130265
|
if (file.packageJsonScope) {
|
|
130322
130266
|
(result ?? (result = [])).push(chainDiagnosticMessages(
|
|
@@ -136867,12 +136811,12 @@ function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) {
|
|
|
136867
136811
|
);
|
|
136868
136812
|
return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end));
|
|
136869
136813
|
}
|
|
136870
|
-
function getReplacementSpanForContextToken(contextToken) {
|
|
136814
|
+
function getReplacementSpanForContextToken(contextToken, position) {
|
|
136871
136815
|
if (!contextToken) return void 0;
|
|
136872
136816
|
switch (contextToken.kind) {
|
|
136873
136817
|
case 11 /* StringLiteral */:
|
|
136874
136818
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
136875
|
-
return createTextSpanFromStringLiteralLikeContent(contextToken);
|
|
136819
|
+
return createTextSpanFromStringLiteralLikeContent(contextToken, position);
|
|
136876
136820
|
default:
|
|
136877
136821
|
return createTextSpanFromNode(contextToken);
|
|
136878
136822
|
}
|
|
@@ -136880,11 +136824,11 @@ function getReplacementSpanForContextToken(contextToken) {
|
|
|
136880
136824
|
function createTextSpanFromNode(node, sourceFile, endNode2) {
|
|
136881
136825
|
return createTextSpanFromBounds(node.getStart(sourceFile), (endNode2 || node).getEnd());
|
|
136882
136826
|
}
|
|
136883
|
-
function createTextSpanFromStringLiteralLikeContent(node) {
|
|
136827
|
+
function createTextSpanFromStringLiteralLikeContent(node, position) {
|
|
136884
136828
|
let replacementEnd = node.getEnd() - 1;
|
|
136885
136829
|
if (node.isUnterminated) {
|
|
136886
136830
|
if (node.getStart() === replacementEnd) return void 0;
|
|
136887
|
-
replacementEnd = node.getEnd();
|
|
136831
|
+
replacementEnd = Math.min(position, node.getEnd());
|
|
136888
136832
|
}
|
|
136889
136833
|
return createTextSpanFromBounds(node.getStart() + 1, replacementEnd);
|
|
136890
136834
|
}
|
|
@@ -136934,9 +136878,6 @@ function isTypeKeywordToken(node) {
|
|
|
136934
136878
|
function isTypeKeywordTokenOrIdentifier(node) {
|
|
136935
136879
|
return isTypeKeywordToken(node) || isIdentifier(node) && node.text === "type";
|
|
136936
136880
|
}
|
|
136937
|
-
function isExternalModuleSymbol(moduleSymbol) {
|
|
136938
|
-
return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */;
|
|
136939
|
-
}
|
|
136940
136881
|
function nodeSeenTracker() {
|
|
136941
136882
|
const seen = [];
|
|
136942
136883
|
return (node) => {
|
|
@@ -136987,9 +136928,7 @@ function createModuleSpecifierResolutionHost(program, host) {
|
|
|
136987
136928
|
isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
|
|
136988
136929
|
getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
|
|
136989
136930
|
getFileIncludeReasons: () => program.getFileIncludeReasons(),
|
|
136990
|
-
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
136991
|
-
getDefaultResolutionModeForFile: (file) => program.getDefaultResolutionModeForFile(file),
|
|
136992
|
-
getModeForResolutionAtIndex: (file, index) => program.getModeForResolutionAtIndex(file, index)
|
|
136931
|
+
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
|
|
136993
136932
|
};
|
|
136994
136933
|
}
|
|
136995
136934
|
function getModuleSpecifierResolverHost(program, host) {
|
|
@@ -138295,13 +138234,9 @@ function fileShouldUseJavaScriptRequire(file, program, host, preferRequire) {
|
|
|
138295
138234
|
if (!hasJSFileExtension(fileName)) {
|
|
138296
138235
|
return false;
|
|
138297
138236
|
}
|
|
138298
|
-
const compilerOptions =
|
|
138237
|
+
const compilerOptions = program.getCompilerOptions();
|
|
138299
138238
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
138300
|
-
const
|
|
138301
|
-
fileName: file,
|
|
138302
|
-
impliedNodeFormat: getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), host, compilerOptions)
|
|
138303
|
-
} : file;
|
|
138304
|
-
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;
|
|
138305
138240
|
if (impliedNodeFormat === 99 /* ESNext */) {
|
|
138306
138241
|
return false;
|
|
138307
138242
|
}
|
|
@@ -141281,7 +141216,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
141281
141216
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
141282
141217
|
const diags = [];
|
|
141283
141218
|
const checker = program.getTypeChecker();
|
|
141284
|
-
const isCommonJSFile =
|
|
141219
|
+
const isCommonJSFile = sourceFile.impliedNodeFormat === 1 /* CommonJS */ || fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
|
|
141285
141220
|
if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (programContainsEsModules(program) || compilerOptionsIndicateEsModules(program.getCompilerOptions())) && containsTopLevelCommonjs(sourceFile)) {
|
|
141286
141221
|
diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
|
|
141287
141222
|
}
|
|
@@ -141523,8 +141458,9 @@ interface Symbol {
|
|
|
141523
141458
|
readonly [Symbol.toStringTag]: string;
|
|
141524
141459
|
}`;
|
|
141525
141460
|
var barebonesLibName = "lib.d.ts";
|
|
141526
|
-
var barebonesLibSourceFile
|
|
141461
|
+
var barebonesLibSourceFile;
|
|
141527
141462
|
function transpileWorker(input, transpileOptions, declaration) {
|
|
141463
|
+
barebonesLibSourceFile ?? (barebonesLibSourceFile = createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: 99 /* Latest */ }));
|
|
141528
141464
|
const diagnostics = [];
|
|
141529
141465
|
const options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};
|
|
141530
141466
|
const defaultOptions = getDefaultCompilerOptions2();
|
|
@@ -143994,7 +143930,7 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
143994
143930
|
const unusedImportsFromOldFile = /* @__PURE__ */ new Set();
|
|
143995
143931
|
for (const statement of toMove) {
|
|
143996
143932
|
forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
|
|
143997
|
-
if (!symbol.declarations) {
|
|
143933
|
+
if (!symbol.declarations || isGlobalType(checker, symbol)) {
|
|
143998
143934
|
return;
|
|
143999
143935
|
}
|
|
144000
143936
|
if (existingTargetLocals.has(skipAlias(symbol, checker))) {
|
|
@@ -144044,6 +143980,16 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
144044
143980
|
return !!jsxNamespaceSymbol2 && some(jsxNamespaceSymbol2.declarations, isInImport) ? jsxNamespaceSymbol2 : void 0;
|
|
144045
143981
|
}
|
|
144046
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
|
+
}
|
|
144047
143993
|
function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
|
|
144048
143994
|
let newFilename = proposedFilename;
|
|
144049
143995
|
for (let i = 1; ; i++) {
|
|
@@ -154277,7 +154223,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
154277
154223
|
compilerOptions,
|
|
154278
154224
|
createModuleSpecifierResolutionHost(program, host)
|
|
154279
154225
|
);
|
|
154280
|
-
const importKind = getImportKind(futureExportingSourceFile, exportKind,
|
|
154226
|
+
const importKind = getImportKind(futureExportingSourceFile, exportKind, compilerOptions);
|
|
154281
154227
|
const addAsTypeOnly = getAddAsTypeOnly(
|
|
154282
154228
|
isImportUsageValidAsTypeOnly,
|
|
154283
154229
|
/*isForNewImportDeclaration*/
|
|
@@ -154617,7 +154563,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
154617
154563
|
}
|
|
154618
154564
|
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
|
154619
154565
|
const packageJsonImportFilter = createPackageJsonImportFilter(importingFile, preferences, host);
|
|
154620
|
-
const importMap = createExistingImportMap(importingFile, program);
|
|
154566
|
+
const importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
|
154621
154567
|
return { getModuleSpecifierForBestExportInfo };
|
|
154622
154568
|
function getModuleSpecifierForBestExportInfo(exportInfo, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
|
154623
154569
|
const { fixes, computedWithoutCacheCount } = getImportFixes(
|
|
@@ -154720,7 +154666,7 @@ function getSingleExportInfoForSymbol(symbol, symbolName2, moduleSymbol, program
|
|
|
154720
154666
|
}
|
|
154721
154667
|
}
|
|
154722
154668
|
}
|
|
154723
|
-
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) {
|
|
154724
154670
|
const checker = program.getTypeChecker();
|
|
154725
154671
|
const existingImports = importMap ? flatMap(exportInfos, importMap.getImportsForExportInfo) : emptyArray;
|
|
154726
154672
|
const useNamespace = usagePosition !== void 0 && tryUseExistingNamespaceImport(existingImports, usagePosition);
|
|
@@ -154835,8 +154781,7 @@ function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker
|
|
|
154835
154781
|
};
|
|
154836
154782
|
}
|
|
154837
154783
|
}
|
|
154838
|
-
function createExistingImportMap(importingFile,
|
|
154839
|
-
const checker = program.getTypeChecker();
|
|
154784
|
+
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
|
154840
154785
|
let importMap;
|
|
154841
154786
|
for (const moduleSpecifier of importingFile.imports) {
|
|
154842
154787
|
const i = importFromModuleSpecifier(moduleSpecifier);
|
|
@@ -154857,7 +154802,7 @@ function createExistingImportMap(importingFile, program) {
|
|
|
154857
154802
|
const matchingDeclarations = importMap == null ? void 0 : importMap.get(getSymbolId(moduleSymbol));
|
|
154858
154803
|
if (!matchingDeclarations) return emptyArray;
|
|
154859
154804
|
if (isSourceFileJS(importingFile) && !(targetFlags & 111551 /* Value */) && !every(matchingDeclarations, isJSDocImportTag)) return emptyArray;
|
|
154860
|
-
const importKind = getImportKind(importingFile, exportKind,
|
|
154805
|
+
const importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
154861
154806
|
return matchingDeclarations.map((declaration) => ({ declaration, importKind, symbol, targetFlags }));
|
|
154862
154807
|
}
|
|
154863
154808
|
};
|
|
@@ -154872,8 +154817,8 @@ function shouldUseRequire(sourceFile, program) {
|
|
|
154872
154817
|
if (compilerOptions.configFile) {
|
|
154873
154818
|
return getEmitModuleKind(compilerOptions) < 5 /* ES2015 */;
|
|
154874
154819
|
}
|
|
154875
|
-
if (
|
|
154876
|
-
if (
|
|
154820
|
+
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */) return true;
|
|
154821
|
+
if (sourceFile.impliedNodeFormat === 99 /* ESNext */) return false;
|
|
154877
154822
|
for (const otherFile of program.getSourceFiles()) {
|
|
154878
154823
|
if (otherFile === sourceFile || !isSourceFileJS(otherFile) || program.isSourceFileFromExternalLibrary(otherFile)) continue;
|
|
154879
154824
|
if (otherFile.commonJsModuleIndicator && !otherFile.externalModuleIndicator) return true;
|
|
@@ -154925,7 +154870,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
|
|
|
154925
154870
|
if (!importedSymbolHasValueMeaning && isJs && usagePosition !== void 0) {
|
|
154926
154871
|
return { kind: 1 /* JsdocTypeImport */, moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo: exportInfo2, isReExport: i > 0 };
|
|
154927
154872
|
}
|
|
154928
|
-
const importKind = getImportKind(sourceFile, exportInfo2.exportKind,
|
|
154873
|
+
const importKind = getImportKind(sourceFile, exportInfo2.exportKind, compilerOptions);
|
|
154929
154874
|
let qualification;
|
|
154930
154875
|
if (usagePosition !== void 0 && importKind === 3 /* CommonJS */ && exportInfo2.exportKind === 0 /* Named */) {
|
|
154931
154876
|
const exportEquals = checker.resolveExternalModuleSymbol(exportInfo2.moduleSymbol);
|
|
@@ -155111,8 +155056,8 @@ function getUmdSymbol(token, checker) {
|
|
|
155111
155056
|
}
|
|
155112
155057
|
return void 0;
|
|
155113
155058
|
}
|
|
155114
|
-
function getImportKind(importingFile, exportKind,
|
|
155115
|
-
if (
|
|
155059
|
+
function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) {
|
|
155060
|
+
if (compilerOptions.verbatimModuleSyntax && (getEmitModuleKind(compilerOptions) === 1 /* CommonJS */ || importingFile.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
155116
155061
|
return 3 /* CommonJS */;
|
|
155117
155062
|
}
|
|
155118
155063
|
switch (exportKind) {
|
|
@@ -155121,18 +155066,18 @@ function getImportKind(importingFile, exportKind, program, forceImportKeyword) {
|
|
|
155121
155066
|
case 1 /* Default */:
|
|
155122
155067
|
return 1 /* Default */;
|
|
155123
155068
|
case 2 /* ExportEquals */:
|
|
155124
|
-
return getExportEqualsImportKind(importingFile,
|
|
155069
|
+
return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword);
|
|
155125
155070
|
case 3 /* UMD */:
|
|
155126
|
-
return getUmdImportKind(importingFile,
|
|
155071
|
+
return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword);
|
|
155127
155072
|
default:
|
|
155128
155073
|
return Debug.assertNever(exportKind);
|
|
155129
155074
|
}
|
|
155130
155075
|
}
|
|
155131
|
-
function getUmdImportKind(importingFile,
|
|
155132
|
-
if (getAllowSyntheticDefaultImports(
|
|
155076
|
+
function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
|
|
155077
|
+
if (getAllowSyntheticDefaultImports(compilerOptions)) {
|
|
155133
155078
|
return 1 /* Default */;
|
|
155134
155079
|
}
|
|
155135
|
-
const moduleKind = getEmitModuleKind(
|
|
155080
|
+
const moduleKind = getEmitModuleKind(compilerOptions);
|
|
155136
155081
|
switch (moduleKind) {
|
|
155137
155082
|
case 2 /* AMD */:
|
|
155138
155083
|
case 1 /* CommonJS */:
|
|
@@ -155151,7 +155096,7 @@ function getUmdImportKind(importingFile, program, forceImportKeyword) {
|
|
|
155151
155096
|
return 2 /* Namespace */;
|
|
155152
155097
|
case 100 /* Node16 */:
|
|
155153
155098
|
case 199 /* NodeNext */:
|
|
155154
|
-
return
|
|
155099
|
+
return importingFile.impliedNodeFormat === 99 /* ESNext */ ? 2 /* Namespace */ : 3 /* CommonJS */;
|
|
155155
155100
|
default:
|
|
155156
155101
|
return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`);
|
|
155157
155102
|
}
|
|
@@ -155635,12 +155580,6 @@ function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) {
|
|
|
155635
155580
|
function symbolFlagsHaveMeaning(flags, meaning) {
|
|
155636
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;
|
|
155637
155582
|
}
|
|
155638
|
-
function getImpliedNodeFormatForEmit(file, program) {
|
|
155639
|
-
return isFullSourceFile(file) ? program.getImpliedNodeFormatForEmit(file) : getImpliedNodeFormatForEmitWorker(file, program.getCompilerOptions());
|
|
155640
|
-
}
|
|
155641
|
-
function getEmitModuleFormatOfFile(file, program) {
|
|
155642
|
-
return isFullSourceFile(file) ? program.getEmitModuleFormatOfFile(file) : getEmitModuleFormatOfFileWorker(file, program.getCompilerOptions());
|
|
155643
|
-
}
|
|
155644
155583
|
|
|
155645
155584
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
155646
155585
|
var fixId17 = "addMissingConstraint";
|
|
@@ -158687,6 +158626,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
158687
158626
|
textChanges: changeTracker.getChanges()
|
|
158688
158627
|
};
|
|
158689
158628
|
function addTypeAnnotation(span) {
|
|
158629
|
+
context.cancellationToken.throwIfCancellationRequested();
|
|
158690
158630
|
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
|
158691
158631
|
const expandoFunction = findExpandoFunction(nodeWithDiag);
|
|
158692
158632
|
if (expandoFunction) {
|
|
@@ -158758,6 +158698,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
158758
158698
|
return factory.createAsExpression(factory.createSatisfiesExpression(node, getSynthesizedDeepClone(type)), type);
|
|
158759
158699
|
}
|
|
158760
158700
|
function addInlineAssertion(span) {
|
|
158701
|
+
context.cancellationToken.throwIfCancellationRequested();
|
|
158761
158702
|
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
|
158762
158703
|
const expandoFunction = findExpandoFunction(nodeWithDiag);
|
|
158763
158704
|
if (expandoFunction) return;
|
|
@@ -158815,6 +158756,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
158815
158756
|
return [Diagnostics.Add_satisfies_and_an_inline_type_assertion_with_0, typeToStringForDiag(typeNode)];
|
|
158816
158757
|
}
|
|
158817
158758
|
function extractAsVariable(span) {
|
|
158759
|
+
context.cancellationToken.throwIfCancellationRequested();
|
|
158818
158760
|
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
|
158819
158761
|
const targetNode = findBestFittingNode(nodeWithDiag, span);
|
|
158820
158762
|
if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent)) return;
|
|
@@ -162910,12 +162852,10 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
|
|
|
162910
162852
|
const printer = isSnippet ? createSnippetPrinter({
|
|
162911
162853
|
removeComments: true,
|
|
162912
162854
|
module: options.module,
|
|
162913
|
-
moduleResolution: options.moduleResolution,
|
|
162914
162855
|
target: options.target
|
|
162915
162856
|
}) : createPrinter({
|
|
162916
162857
|
removeComments: true,
|
|
162917
162858
|
module: options.module,
|
|
162918
|
-
moduleResolution: options.moduleResolution,
|
|
162919
162859
|
target: options.target
|
|
162920
162860
|
});
|
|
162921
162861
|
setEmitFlags(typeNode, 1 /* SingleLine */);
|
|
@@ -163171,7 +163111,6 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
|
|
|
163171
163111
|
const printer = createSnippetPrinter({
|
|
163172
163112
|
removeComments: true,
|
|
163173
163113
|
module: options.module,
|
|
163174
|
-
moduleResolution: options.moduleResolution,
|
|
163175
163114
|
target: options.target,
|
|
163176
163115
|
newLine: getNewLineKind(newLineChar)
|
|
163177
163116
|
});
|
|
@@ -163311,7 +163250,7 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
163311
163250
|
var _a, _b;
|
|
163312
163251
|
let insertText;
|
|
163313
163252
|
let filterText;
|
|
163314
|
-
let replacementSpan = getReplacementSpanForContextToken(replacementToken);
|
|
163253
|
+
let replacementSpan = getReplacementSpanForContextToken(replacementToken, position);
|
|
163315
163254
|
let data;
|
|
163316
163255
|
let isSnippet;
|
|
163317
163256
|
let source = getSourceFromOrigin(origin);
|
|
@@ -163358,7 +163297,7 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
163358
163297
|
if (originIsResolvedExport(origin)) {
|
|
163359
163298
|
sourceDisplay = [textPart(origin.moduleSpecifier)];
|
|
163360
163299
|
if (importStatementCompletion) {
|
|
163361
|
-
({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile,
|
|
163300
|
+
({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences));
|
|
163362
163301
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : void 0;
|
|
163363
163302
|
}
|
|
163364
163303
|
}
|
|
@@ -163474,7 +163413,6 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
|
|
|
163474
163413
|
const printer = createSnippetPrinter({
|
|
163475
163414
|
removeComments: true,
|
|
163476
163415
|
module: options.module,
|
|
163477
|
-
moduleResolution: options.moduleResolution,
|
|
163478
163416
|
target: options.target,
|
|
163479
163417
|
omitTrailingSemicolon: false,
|
|
163480
163418
|
newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
|
|
@@ -163625,7 +163563,6 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
|
|
|
163625
163563
|
const printer = createSnippetPrinter({
|
|
163626
163564
|
removeComments: true,
|
|
163627
163565
|
module: options.module,
|
|
163628
|
-
moduleResolution: options.moduleResolution,
|
|
163629
163566
|
target: options.target,
|
|
163630
163567
|
omitTrailingSemicolon: false,
|
|
163631
163568
|
newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
|
|
@@ -163646,7 +163583,6 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
|
|
|
163646
163583
|
const signaturePrinter = createPrinter({
|
|
163647
163584
|
removeComments: true,
|
|
163648
163585
|
module: options.module,
|
|
163649
|
-
moduleResolution: options.moduleResolution,
|
|
163650
163586
|
target: options.target,
|
|
163651
163587
|
omitTrailingSemicolon: true
|
|
163652
163588
|
});
|
|
@@ -163908,7 +163844,7 @@ function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbo
|
|
|
163908
163844
|
};
|
|
163909
163845
|
return unresolvedOrigin;
|
|
163910
163846
|
}
|
|
163911
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile,
|
|
163847
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
|
|
163912
163848
|
const replacementSpan = importStatementCompletion.replacementSpan;
|
|
163913
163849
|
const quotedModuleSpecifier = escapeSnippetText(quote(sourceFile, preferences, origin.moduleSpecifier));
|
|
163914
163850
|
const exportKind = origin.isDefaultExport ? 1 /* Default */ : origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */;
|
|
@@ -163916,7 +163852,7 @@ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatemen
|
|
|
163916
163852
|
const importKind = ts_codefix_exports.getImportKind(
|
|
163917
163853
|
sourceFile,
|
|
163918
163854
|
exportKind,
|
|
163919
|
-
|
|
163855
|
+
options,
|
|
163920
163856
|
/*forceImportKeyword*/
|
|
163921
163857
|
true
|
|
163922
163858
|
);
|
|
@@ -166292,7 +166228,7 @@ function createNameAndKindSet() {
|
|
|
166292
166228
|
}
|
|
166293
166229
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences, includeSymbol) {
|
|
166294
166230
|
if (isInReferenceComment(sourceFile, position)) {
|
|
166295
|
-
const entries = getTripleSlashReferenceCompletion(sourceFile, position,
|
|
166231
|
+
const entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
166296
166232
|
return entries && convertPathCompletions(entries);
|
|
166297
166233
|
}
|
|
166298
166234
|
if (isInString(sourceFile, position, contextToken)) {
|
|
@@ -166305,7 +166241,7 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|
|
166305
166241
|
if (completion === void 0) {
|
|
166306
166242
|
return void 0;
|
|
166307
166243
|
}
|
|
166308
|
-
const optionalReplacementSpan = createTextSpanFromStringLiteralLikeContent(contextToken);
|
|
166244
|
+
const optionalReplacementSpan = createTextSpanFromStringLiteralLikeContent(contextToken, position);
|
|
166309
166245
|
switch (completion.kind) {
|
|
166310
166246
|
case 0 /* Paths */:
|
|
166311
166247
|
return convertPathCompletions(completion.paths);
|
|
@@ -166359,7 +166295,7 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|
|
166359
166295
|
kindModifiers: "" /* none */,
|
|
166360
166296
|
kind: "string" /* string */,
|
|
166361
166297
|
sortText: SortText.LocationPriority,
|
|
166362
|
-
replacementSpan: getReplacementSpanForContextToken(contextToken)
|
|
166298
|
+
replacementSpan: getReplacementSpanForContextToken(contextToken, position)
|
|
166363
166299
|
}));
|
|
166364
166300
|
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, optionalReplacementSpan, entries };
|
|
166365
166301
|
}
|
|
@@ -166600,7 +166536,7 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, prog
|
|
|
166600
166536
|
const compilerOptions = program.getCompilerOptions();
|
|
166601
166537
|
const typeChecker = program.getTypeChecker();
|
|
166602
166538
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
|
166603
|
-
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);
|
|
166604
166540
|
}
|
|
166605
166541
|
function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile, typeChecker, preferences, resolutionMode) {
|
|
166606
166542
|
return {
|
|
@@ -166611,15 +166547,14 @@ function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile
|
|
|
166611
166547
|
resolutionMode
|
|
166612
166548
|
};
|
|
166613
166549
|
}
|
|
166614
|
-
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory,
|
|
166615
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166550
|
+
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) {
|
|
166616
166551
|
if (compilerOptions.rootDirs) {
|
|
166617
166552
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(
|
|
166618
166553
|
compilerOptions.rootDirs,
|
|
166619
166554
|
literalValue,
|
|
166620
166555
|
scriptDirectory,
|
|
166621
166556
|
extensionOptions,
|
|
166622
|
-
|
|
166557
|
+
compilerOptions,
|
|
166623
166558
|
host,
|
|
166624
166559
|
scriptPath
|
|
166625
166560
|
);
|
|
@@ -166628,7 +166563,6 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
|
166628
166563
|
literalValue,
|
|
166629
166564
|
scriptDirectory,
|
|
166630
166565
|
extensionOptions,
|
|
166631
|
-
program,
|
|
166632
166566
|
host,
|
|
166633
166567
|
/*moduleSpecifierIsRelative*/
|
|
166634
166568
|
true,
|
|
@@ -166655,8 +166589,7 @@ function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ign
|
|
|
166655
166589
|
compareStringsCaseSensitive
|
|
166656
166590
|
);
|
|
166657
166591
|
}
|
|
166658
|
-
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions,
|
|
166659
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166592
|
+
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) {
|
|
166660
166593
|
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
|
166661
166594
|
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
|
166662
166595
|
const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
|
@@ -166665,7 +166598,6 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
166665
166598
|
fragment,
|
|
166666
166599
|
baseDirectory,
|
|
166667
166600
|
extensionOptions,
|
|
166668
|
-
program,
|
|
166669
166601
|
host,
|
|
166670
166602
|
/*moduleSpecifierIsRelative*/
|
|
166671
166603
|
true,
|
|
@@ -166674,7 +166606,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
166674
166606
|
(itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
|
|
166675
166607
|
);
|
|
166676
166608
|
}
|
|
166677
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions,
|
|
166609
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
|
166678
166610
|
var _a;
|
|
166679
166611
|
if (fragment === void 0) {
|
|
166680
166612
|
fragment = "";
|
|
@@ -166699,7 +166631,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166699
166631
|
if (versionPaths) {
|
|
166700
166632
|
const packageDirectory = getDirectoryPath(packageJsonPath);
|
|
166701
166633
|
const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
|
|
166702
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions,
|
|
166634
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
|
|
166703
166635
|
return result;
|
|
166704
166636
|
}
|
|
166705
166637
|
}
|
|
@@ -166725,7 +166657,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166725
166657
|
}
|
|
166726
166658
|
const { name, extension } = getFilenameWithExtensionOption(
|
|
166727
166659
|
getBaseFileName(filePath),
|
|
166728
|
-
|
|
166660
|
+
host.getCompilationSettings(),
|
|
166729
166661
|
extensionOptions,
|
|
166730
166662
|
/*isExportsWildcard*/
|
|
166731
166663
|
false
|
|
@@ -166744,7 +166676,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
166744
166676
|
}
|
|
166745
166677
|
return result;
|
|
166746
166678
|
}
|
|
166747
|
-
function getFilenameWithExtensionOption(name,
|
|
166679
|
+
function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions, isExportsWildcard) {
|
|
166748
166680
|
const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
|
|
166749
166681
|
if (nonJsResult) {
|
|
166750
166682
|
return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
|
|
@@ -166754,8 +166686,7 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
166754
166686
|
}
|
|
166755
166687
|
let allowedEndings = getModuleSpecifierPreferences(
|
|
166756
166688
|
{ importModuleSpecifierEnding: extensionOptions.endingPreference },
|
|
166757
|
-
|
|
166758
|
-
program.getCompilerOptions(),
|
|
166689
|
+
compilerOptions,
|
|
166759
166690
|
extensionOptions.importingSourceFile
|
|
166760
166691
|
).getAllowedEndingsInPreferredOrder(extensionOptions.resolutionMode);
|
|
166761
166692
|
if (isExportsWildcard) {
|
|
@@ -166765,16 +166696,16 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
166765
166696
|
if (fileExtensionIsOneOf(name, supportedTSImplementationExtensions)) {
|
|
166766
166697
|
return { name, extension: tryGetExtensionFromPath2(name) };
|
|
166767
166698
|
}
|
|
166768
|
-
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name,
|
|
166699
|
+
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
|
|
166769
166700
|
return outputExtension2 ? { name: changeExtension(name, outputExtension2), extension: outputExtension2 } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
166770
166701
|
}
|
|
166771
166702
|
if (!isExportsWildcard && (allowedEndings[0] === 0 /* Minimal */ || allowedEndings[0] === 1 /* Index */) && fileExtensionIsOneOf(name, [".js" /* Js */, ".jsx" /* Jsx */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */])) {
|
|
166772
166703
|
return { name: removeFileExtension(name), extension: tryGetExtensionFromPath2(name) };
|
|
166773
166704
|
}
|
|
166774
|
-
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name,
|
|
166705
|
+
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
|
|
166775
166706
|
return outputExtension ? { name: changeExtension(name, outputExtension), extension: outputExtension } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
166776
166707
|
}
|
|
166777
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions,
|
|
166708
|
+
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
|
|
166778
166709
|
const getPatternsForKey = (key) => paths[key];
|
|
166779
166710
|
const comparePaths2 = (a, b) => {
|
|
166780
166711
|
const patternA = tryParsePattern(a);
|
|
@@ -166790,14 +166721,13 @@ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensio
|
|
|
166790
166721
|
fragment,
|
|
166791
166722
|
baseDirectory,
|
|
166792
166723
|
extensionOptions,
|
|
166793
|
-
program,
|
|
166794
166724
|
host,
|
|
166795
166725
|
getOwnKeys(paths),
|
|
166796
166726
|
getPatternsForKey,
|
|
166797
166727
|
comparePaths2
|
|
166798
166728
|
);
|
|
166799
166729
|
}
|
|
166800
|
-
function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions,
|
|
166730
|
+
function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths2) {
|
|
166801
166731
|
let pathResults = [];
|
|
166802
166732
|
let matchedPath;
|
|
166803
166733
|
for (const key of keys) {
|
|
@@ -166816,7 +166746,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
|
166816
166746
|
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(key, matchedPath) !== 1 /* GreaterThan */) {
|
|
166817
166747
|
pathResults.push({
|
|
166818
166748
|
matchedPattern: isMatch,
|
|
166819
|
-
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))
|
|
166820
166750
|
});
|
|
166821
166751
|
}
|
|
166822
166752
|
}
|
|
@@ -166824,9 +166754,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
|
166824
166754
|
pathResults.forEach((pathResult) => pathResult.results.forEach((r) => result.add(r)));
|
|
166825
166755
|
return matchedPath !== void 0;
|
|
166826
166756
|
}
|
|
166827
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode,
|
|
166828
|
-
const typeChecker = program.getTypeChecker();
|
|
166829
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166757
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, extensionOptions, typeChecker) {
|
|
166830
166758
|
const { baseUrl, paths } = compilerOptions;
|
|
166831
166759
|
const result = createNameAndKindSet();
|
|
166832
166760
|
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
@@ -166836,7 +166764,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166836
166764
|
fragment,
|
|
166837
166765
|
absolute,
|
|
166838
166766
|
extensionOptions,
|
|
166839
|
-
program,
|
|
166840
166767
|
host,
|
|
166841
166768
|
/*moduleSpecifierIsRelative*/
|
|
166842
166769
|
false,
|
|
@@ -166847,7 +166774,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166847
166774
|
}
|
|
166848
166775
|
if (paths) {
|
|
166849
166776
|
const absolute = getPathsBasePath(compilerOptions, host);
|
|
166850
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions,
|
|
166777
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
|
|
166851
166778
|
}
|
|
166852
166779
|
const fragmentDirectory = getFragmentDirectory(fragment);
|
|
166853
166780
|
for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
|
|
@@ -166858,7 +166785,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166858
166785
|
void 0
|
|
166859
166786
|
));
|
|
166860
166787
|
}
|
|
166861
|
-
getCompletionEntriesFromTypings(host,
|
|
166788
|
+
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
166862
166789
|
if (moduleResolutionUsesNodeModules(moduleResolution)) {
|
|
166863
166790
|
let foundGlobal = false;
|
|
166864
166791
|
if (fragmentDirectory === void 0) {
|
|
@@ -166883,7 +166810,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166883
166810
|
fragment,
|
|
166884
166811
|
nodeModules,
|
|
166885
166812
|
extensionOptions,
|
|
166886
|
-
program,
|
|
166887
166813
|
host,
|
|
166888
166814
|
/*moduleSpecifierIsRelative*/
|
|
166889
166815
|
false,
|
|
@@ -166928,7 +166854,6 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
166928
166854
|
fragmentSubpath,
|
|
166929
166855
|
packageDirectory,
|
|
166930
166856
|
extensionOptions,
|
|
166931
|
-
program,
|
|
166932
166857
|
host,
|
|
166933
166858
|
keys,
|
|
166934
166859
|
(key) => singleElementArray(getPatternFromFirstMatchingCondition(exports2[key], conditions)),
|
|
@@ -166961,7 +166886,7 @@ function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
|
166961
166886
|
function getFragmentDirectory(fragment) {
|
|
166962
166887
|
return containsSlash(fragment) ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
|
166963
166888
|
}
|
|
166964
|
-
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard,
|
|
166889
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard, host) {
|
|
166965
166890
|
if (!endsWith(path, "*")) {
|
|
166966
166891
|
return !path.includes("*") ? justPathMappingName(path, "script" /* scriptElement */) : emptyArray;
|
|
166967
166892
|
}
|
|
@@ -166971,15 +166896,15 @@ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory
|
|
|
166971
166896
|
const starIsFullPathComponent = path[path.length - 2] === "/";
|
|
166972
166897
|
return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : flatMap(patterns, (pattern) => {
|
|
166973
166898
|
var _a;
|
|
166974
|
-
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 }));
|
|
166975
166900
|
});
|
|
166976
166901
|
}
|
|
166977
|
-
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard,
|
|
166902
|
+
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host));
|
|
166978
166903
|
function justPathMappingName(name, kind) {
|
|
166979
166904
|
return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: void 0 }] : emptyArray;
|
|
166980
166905
|
}
|
|
166981
166906
|
}
|
|
166982
|
-
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard,
|
|
166907
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host) {
|
|
166983
166908
|
if (!host.readDirectory) {
|
|
166984
166909
|
return void 0;
|
|
166985
166910
|
}
|
|
@@ -167012,7 +166937,7 @@ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensio
|
|
|
167012
166937
|
if (containsSlash(trimmedWithPattern)) {
|
|
167013
166938
|
return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
|
167014
166939
|
}
|
|
167015
|
-
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern,
|
|
166940
|
+
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions, isExportsWildcard);
|
|
167016
166941
|
return nameAndKind(name, "script" /* scriptElement */, extension);
|
|
167017
166942
|
}
|
|
167018
166943
|
});
|
|
@@ -167040,8 +166965,7 @@ function getAmbientModuleCompletions(fragment, fragmentDirectory, checker) {
|
|
|
167040
166965
|
}
|
|
167041
166966
|
return nonRelativeModuleNames;
|
|
167042
166967
|
}
|
|
167043
|
-
function getTripleSlashReferenceCompletion(sourceFile, position,
|
|
167044
|
-
const compilerOptions = program.getCompilerOptions();
|
|
166968
|
+
function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) {
|
|
167045
166969
|
const token = getTokenAtPosition(sourceFile, position);
|
|
167046
166970
|
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
|
167047
166971
|
const range = commentRanges && find(commentRanges, (commentRange) => position >= commentRange.pos && position <= commentRange.end);
|
|
@@ -167059,16 +166983,14 @@ function getTripleSlashReferenceCompletion(sourceFile, position, program, host)
|
|
|
167059
166983
|
toComplete,
|
|
167060
166984
|
scriptPath,
|
|
167061
166985
|
getExtensionOptions(compilerOptions, 0 /* Filename */, sourceFile),
|
|
167062
|
-
program,
|
|
167063
166986
|
host,
|
|
167064
166987
|
/*moduleSpecifierIsRelative*/
|
|
167065
166988
|
true,
|
|
167066
166989
|
sourceFile.path
|
|
167067
|
-
) : kind === "types" ? getCompletionEntriesFromTypings(host,
|
|
166990
|
+
) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
|
|
167068
166991
|
return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
|
|
167069
166992
|
}
|
|
167070
|
-
function getCompletionEntriesFromTypings(host,
|
|
167071
|
-
const options = program.getCompilerOptions();
|
|
166993
|
+
function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
|
|
167072
166994
|
const seen = /* @__PURE__ */ new Map();
|
|
167073
166995
|
const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
|
|
167074
166996
|
for (const root of typeRoots) {
|
|
@@ -167102,7 +167024,6 @@ function getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDire
|
|
|
167102
167024
|
remainingFragment,
|
|
167103
167025
|
baseDirectory,
|
|
167104
167026
|
extensionOptions,
|
|
167105
|
-
program,
|
|
167106
167027
|
host,
|
|
167107
167028
|
/*moduleSpecifierIsRelative*/
|
|
167108
167029
|
false,
|
|
@@ -178451,7 +178372,6 @@ __export(ts_exports2, {
|
|
|
178451
178372
|
canHaveJSDoc: () => canHaveJSDoc,
|
|
178452
178373
|
canHaveLocals: () => canHaveLocals,
|
|
178453
178374
|
canHaveModifiers: () => canHaveModifiers,
|
|
178454
|
-
canHaveModuleSpecifier: () => canHaveModuleSpecifier,
|
|
178455
178375
|
canHaveSymbol: () => canHaveSymbol,
|
|
178456
178376
|
canIncludeBindAndCheckDiagnsotics: () => canIncludeBindAndCheckDiagnsotics,
|
|
178457
178377
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
@@ -178929,7 +178849,6 @@ __export(ts_exports2, {
|
|
|
178929
178849
|
getDefaultLibFilePath: () => getDefaultLibFilePath,
|
|
178930
178850
|
getDefaultLikeExportInfo: () => getDefaultLikeExportInfo,
|
|
178931
178851
|
getDefaultLikeExportNameFromDeclaration: () => getDefaultLikeExportNameFromDeclaration,
|
|
178932
|
-
getDefaultResolutionModeForFileWorker: () => getDefaultResolutionModeForFileWorker,
|
|
178933
178852
|
getDiagnosticText: () => getDiagnosticText,
|
|
178934
178853
|
getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
|
|
178935
178854
|
getDirectoryPath: () => getDirectoryPath,
|
|
@@ -178960,7 +178879,6 @@ __export(ts_exports2, {
|
|
|
178960
178879
|
getEmitFlags: () => getEmitFlags,
|
|
178961
178880
|
getEmitHelpers: () => getEmitHelpers,
|
|
178962
178881
|
getEmitModuleDetectionKind: () => getEmitModuleDetectionKind,
|
|
178963
|
-
getEmitModuleFormatOfFileWorker: () => getEmitModuleFormatOfFileWorker,
|
|
178964
178882
|
getEmitModuleKind: () => getEmitModuleKind,
|
|
178965
178883
|
getEmitModuleResolutionKind: () => getEmitModuleResolutionKind,
|
|
178966
178884
|
getEmitScriptTarget: () => getEmitScriptTarget,
|
|
@@ -179011,7 +178929,6 @@ __export(ts_exports2, {
|
|
|
179011
178929
|
getIdentifierGeneratedImportReference: () => getIdentifierGeneratedImportReference,
|
|
179012
178930
|
getIdentifierTypeArguments: () => getIdentifierTypeArguments,
|
|
179013
178931
|
getImmediatelyInvokedFunctionExpression: () => getImmediatelyInvokedFunctionExpression,
|
|
179014
|
-
getImpliedNodeFormatForEmitWorker: () => getImpliedNodeFormatForEmitWorker,
|
|
179015
178932
|
getImpliedNodeFormatForFile: () => getImpliedNodeFormatForFile,
|
|
179016
178933
|
getImpliedNodeFormatForFileWorker: () => getImpliedNodeFormatForFileWorker,
|
|
179017
178934
|
getImportNeedsImportDefaultHelper: () => getImportNeedsImportDefaultHelper,
|
|
@@ -179371,7 +179288,6 @@ __export(ts_exports2, {
|
|
|
179371
179288
|
importDefaultHelper: () => importDefaultHelper,
|
|
179372
179289
|
importFromModuleSpecifier: () => importFromModuleSpecifier,
|
|
179373
179290
|
importStarHelper: () => importStarHelper,
|
|
179374
|
-
importSyntaxAffectsModuleResolution: () => importSyntaxAffectsModuleResolution,
|
|
179375
179291
|
indexOfAnyCharCode: () => indexOfAnyCharCode,
|
|
179376
179292
|
indexOfNode: () => indexOfNode,
|
|
179377
179293
|
indicesOf: () => indicesOf,
|
|
@@ -180466,11 +180382,11 @@ __export(ts_exports2, {
|
|
|
180466
180382
|
transformESDecorators: () => transformESDecorators,
|
|
180467
180383
|
transformESNext: () => transformESNext,
|
|
180468
180384
|
transformGenerators: () => transformGenerators,
|
|
180469
|
-
transformImpliedNodeFormatDependentModule: () => transformImpliedNodeFormatDependentModule,
|
|
180470
180385
|
transformJsx: () => transformJsx,
|
|
180471
180386
|
transformLegacyDecorators: () => transformLegacyDecorators,
|
|
180472
180387
|
transformModule: () => transformModule,
|
|
180473
180388
|
transformNamedEvaluation: () => transformNamedEvaluation,
|
|
180389
|
+
transformNodeModule: () => transformNodeModule,
|
|
180474
180390
|
transformNodes: () => transformNodes,
|
|
180475
180391
|
transformSystemModule: () => transformSystemModule,
|
|
180476
180392
|
transformTypeScript: () => transformTypeScript,
|
|
@@ -183841,8 +183757,11 @@ var Project3 = class _Project {
|
|
|
183841
183757
|
const originalText = Debug.checkDefined(rootSourceFile.getText());
|
|
183842
183758
|
(_b = this.getScriptInfo(rootFile)) == null ? void 0 : _b.editContent(0, originalText.length, updatedText);
|
|
183843
183759
|
this.updateGraph();
|
|
183844
|
-
|
|
183845
|
-
|
|
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
|
+
}
|
|
183846
183765
|
}
|
|
183847
183766
|
/** @internal */
|
|
183848
183767
|
getCompilerOptionsForNoDtsResolutionProject() {
|
|
@@ -192883,7 +192802,6 @@ if (typeof console !== "undefined") {
|
|
|
192883
192802
|
canHaveJSDoc,
|
|
192884
192803
|
canHaveLocals,
|
|
192885
192804
|
canHaveModifiers,
|
|
192886
|
-
canHaveModuleSpecifier,
|
|
192887
192805
|
canHaveSymbol,
|
|
192888
192806
|
canIncludeBindAndCheckDiagnsotics,
|
|
192889
192807
|
canJsonReportNoInputFiles,
|
|
@@ -193361,7 +193279,6 @@ if (typeof console !== "undefined") {
|
|
|
193361
193279
|
getDefaultLibFilePath,
|
|
193362
193280
|
getDefaultLikeExportInfo,
|
|
193363
193281
|
getDefaultLikeExportNameFromDeclaration,
|
|
193364
|
-
getDefaultResolutionModeForFileWorker,
|
|
193365
193282
|
getDiagnosticText,
|
|
193366
193283
|
getDiagnosticsWithinSpan,
|
|
193367
193284
|
getDirectoryPath,
|
|
@@ -193392,7 +193309,6 @@ if (typeof console !== "undefined") {
|
|
|
193392
193309
|
getEmitFlags,
|
|
193393
193310
|
getEmitHelpers,
|
|
193394
193311
|
getEmitModuleDetectionKind,
|
|
193395
|
-
getEmitModuleFormatOfFileWorker,
|
|
193396
193312
|
getEmitModuleKind,
|
|
193397
193313
|
getEmitModuleResolutionKind,
|
|
193398
193314
|
getEmitScriptTarget,
|
|
@@ -193443,7 +193359,6 @@ if (typeof console !== "undefined") {
|
|
|
193443
193359
|
getIdentifierGeneratedImportReference,
|
|
193444
193360
|
getIdentifierTypeArguments,
|
|
193445
193361
|
getImmediatelyInvokedFunctionExpression,
|
|
193446
|
-
getImpliedNodeFormatForEmitWorker,
|
|
193447
193362
|
getImpliedNodeFormatForFile,
|
|
193448
193363
|
getImpliedNodeFormatForFileWorker,
|
|
193449
193364
|
getImportNeedsImportDefaultHelper,
|
|
@@ -193803,7 +193718,6 @@ if (typeof console !== "undefined") {
|
|
|
193803
193718
|
importDefaultHelper,
|
|
193804
193719
|
importFromModuleSpecifier,
|
|
193805
193720
|
importStarHelper,
|
|
193806
|
-
importSyntaxAffectsModuleResolution,
|
|
193807
193721
|
indexOfAnyCharCode,
|
|
193808
193722
|
indexOfNode,
|
|
193809
193723
|
indicesOf,
|
|
@@ -194898,11 +194812,11 @@ if (typeof console !== "undefined") {
|
|
|
194898
194812
|
transformESDecorators,
|
|
194899
194813
|
transformESNext,
|
|
194900
194814
|
transformGenerators,
|
|
194901
|
-
transformImpliedNodeFormatDependentModule,
|
|
194902
194815
|
transformJsx,
|
|
194903
194816
|
transformLegacyDecorators,
|
|
194904
194817
|
transformModule,
|
|
194905
194818
|
transformNamedEvaluation,
|
|
194819
|
+
transformNodeModule,
|
|
194906
194820
|
transformNodes,
|
|
194907
194821
|
transformSystemModule,
|
|
194908
194822
|
transformTypeScript,
|
|
@@ -194992,6 +194906,5 @@ if (typeof console !== "undefined") {
|
|
|
194992
194906
|
writeFileEnsuringDirectories,
|
|
194993
194907
|
zipWith
|
|
194994
194908
|
});
|
|
194995
|
-
})(typeof module !== "undefined" && module.exports
|
|
194996
|
-
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; } } })
|
|
194997
194910
|
//# sourceMappingURL=typescript.js.map
|