typescript 5.7.0-dev.20241031 → 5.7.0-dev.20241101
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 +18 -19
- package/lib/typescript.js +276 -107
- package/package.json +2 -2
package/lib/_tsc.js
CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
18
18
|
|
19
19
|
// src/compiler/corePublic.ts
|
20
20
|
var versionMajorMinor = "5.7";
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20241101`;
|
22
22
|
|
23
23
|
// src/compiler/core.ts
|
24
24
|
var emptyArray = [];
|
@@ -40955,7 +40955,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
40955
40955
|
mainExport = scope.contents.packageJsonContent.exports["."];
|
40956
40956
|
}
|
40957
40957
|
if (mainExport) {
|
40958
|
-
const
|
40958
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(
|
40959
40959
|
extensions,
|
40960
40960
|
state,
|
40961
40961
|
cache,
|
@@ -40965,7 +40965,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
40965
40965
|
/*isImports*/
|
40966
40966
|
false
|
40967
40967
|
);
|
40968
|
-
return
|
40968
|
+
return loadModuleFromTargetExportOrImport(
|
40969
40969
|
mainExport,
|
40970
40970
|
"",
|
40971
40971
|
/*pattern*/
|
@@ -40983,7 +40983,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
40983
40983
|
void 0
|
40984
40984
|
);
|
40985
40985
|
}
|
40986
|
-
const result =
|
40986
|
+
const result = loadModuleFromExportsOrImports(
|
40987
40987
|
extensions,
|
40988
40988
|
state,
|
40989
40989
|
cache,
|
@@ -41037,7 +41037,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
|
|
41037
41037
|
void 0
|
41038
41038
|
);
|
41039
41039
|
}
|
41040
|
-
const result =
|
41040
|
+
const result = loadModuleFromExportsOrImports(
|
41041
41041
|
extensions,
|
41042
41042
|
state,
|
41043
41043
|
cache,
|
@@ -41072,11 +41072,11 @@ function comparePatternKeys(a, b) {
|
|
41072
41072
|
if (b.length > a.length) return 1 /* GreaterThan */;
|
41073
41073
|
return 0 /* EqualTo */;
|
41074
41074
|
}
|
41075
|
-
function
|
41076
|
-
const
|
41075
|
+
function loadModuleFromExportsOrImports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
41076
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
41077
41077
|
if (!endsWith(moduleName, directorySeparator) && !moduleName.includes("*") && hasProperty(lookupTable, moduleName)) {
|
41078
41078
|
const target = lookupTable[moduleName];
|
41079
|
-
return
|
41079
|
+
return loadModuleFromTargetExportOrImport(
|
41080
41080
|
target,
|
41081
41081
|
/*subpath*/
|
41082
41082
|
"",
|
@@ -41091,7 +41091,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
41091
41091
|
const target = lookupTable[potentialTarget];
|
41092
41092
|
const starPos = potentialTarget.indexOf("*");
|
41093
41093
|
const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
41094
|
-
return
|
41094
|
+
return loadModuleFromTargetExportOrImport(
|
41095
41095
|
target,
|
41096
41096
|
subpath,
|
41097
41097
|
/*pattern*/
|
@@ -41101,7 +41101,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
41101
41101
|
} else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
41102
41102
|
const target = lookupTable[potentialTarget];
|
41103
41103
|
const subpath = moduleName.substring(potentialTarget.length - 1);
|
41104
|
-
return
|
41104
|
+
return loadModuleFromTargetExportOrImport(
|
41105
41105
|
target,
|
41106
41106
|
subpath,
|
41107
41107
|
/*pattern*/
|
@@ -41111,7 +41111,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
41111
41111
|
} else if (startsWith(moduleName, potentialTarget)) {
|
41112
41112
|
const target = lookupTable[potentialTarget];
|
41113
41113
|
const subpath = moduleName.substring(potentialTarget.length);
|
41114
|
-
return
|
41114
|
+
return loadModuleFromTargetExportOrImport(
|
41115
41115
|
target,
|
41116
41116
|
subpath,
|
41117
41117
|
/*pattern*/
|
@@ -41131,9 +41131,9 @@ function hasOneAsterisk(patternKey) {
|
|
41131
41131
|
const firstStar = patternKey.indexOf("*");
|
41132
41132
|
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
41133
41133
|
}
|
41134
|
-
function
|
41135
|
-
return
|
41136
|
-
function
|
41134
|
+
function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
41135
|
+
return loadModuleFromTargetExportOrImport;
|
41136
|
+
function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
|
41137
41137
|
if (typeof target === "string") {
|
41138
41138
|
if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
|
41139
41139
|
if (state.traceEnabled) {
|
@@ -41223,7 +41223,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
41223
41223
|
if (condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
41224
41224
|
traceIfEnabled(state, Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
41225
41225
|
const subTarget = target[condition];
|
41226
|
-
const result =
|
41226
|
+
const result = loadModuleFromTargetExportOrImport(subTarget, subpath, pattern, key);
|
41227
41227
|
if (result) {
|
41228
41228
|
traceIfEnabled(state, Diagnostics.Resolved_under_condition_0, condition);
|
41229
41229
|
traceIfEnabled(state, Diagnostics.Exiting_conditional_exports);
|
@@ -41248,7 +41248,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
41248
41248
|
);
|
41249
41249
|
}
|
41250
41250
|
for (const elem of target) {
|
41251
|
-
const result =
|
41251
|
+
const result = loadModuleFromTargetExportOrImport(elem, subpath, pattern, key);
|
41252
41252
|
if (result) {
|
41253
41253
|
return result;
|
41254
41254
|
}
|
@@ -49690,7 +49690,7 @@ function createTypeChecker(host) {
|
|
49690
49690
|
const links = getSymbolLinks(symbol);
|
49691
49691
|
const cache = links.accessibleChainCache || (links.accessibleChainCache = /* @__PURE__ */ new Map());
|
49692
49692
|
const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, ___, node) => node);
|
49693
|
-
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation
|
49693
|
+
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation ? getNodeId(firstRelevantLocation) : 0}|${meaning}`;
|
49694
49694
|
if (cache.has(key)) {
|
49695
49695
|
return cache.get(key);
|
49696
49696
|
}
|
@@ -55256,7 +55256,6 @@ function createTypeChecker(host) {
|
|
55256
55256
|
const flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0);
|
55257
55257
|
const symbol = createSymbol(flags, text);
|
55258
55258
|
symbol.links.type = getTypeFromBindingElement(e, includePatternInType, reportErrors2);
|
55259
|
-
symbol.links.bindingElement = e;
|
55260
55259
|
members.set(symbol.escapedName, symbol);
|
55261
55260
|
});
|
55262
55261
|
const result = createAnonymousType(
|
@@ -77661,7 +77660,7 @@ function createTypeChecker(host) {
|
|
77661
77660
|
});
|
77662
77661
|
}
|
77663
77662
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
77664
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
77663
|
+
const antecedent = canHaveFlowNode(expr) && expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
77665
77664
|
2 /* Start */,
|
77666
77665
|
/*node*/
|
77667
77666
|
void 0,
|
package/lib/typescript.js
CHANGED
@@ -945,6 +945,7 @@ __export(typescript_exports, {
|
|
945
945
|
getPositionOfLineAndCharacter: () => getPositionOfLineAndCharacter,
|
946
946
|
getPossibleGenericSignatures: () => getPossibleGenericSignatures,
|
947
947
|
getPossibleOriginalInputExtensionForExtension: () => getPossibleOriginalInputExtensionForExtension,
|
948
|
+
getPossibleOriginalInputPathWithoutChangingExt: () => getPossibleOriginalInputPathWithoutChangingExt,
|
948
949
|
getPossibleTypeArgumentsInfo: () => getPossibleTypeArgumentsInfo,
|
949
950
|
getPreEmitDiagnostics: () => getPreEmitDiagnostics,
|
950
951
|
getPrecedingNonSpaceCharacterPosition: () => getPrecedingNonSpaceCharacterPosition,
|
@@ -2277,7 +2278,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
2277
2278
|
|
2278
2279
|
// src/compiler/corePublic.ts
|
2279
2280
|
var versionMajorMinor = "5.7";
|
2280
|
-
var version = `${versionMajorMinor}.0-dev.
|
2281
|
+
var version = `${versionMajorMinor}.0-dev.20241101`;
|
2281
2282
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
2282
2283
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
2283
2284
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
@@ -20204,6 +20205,12 @@ function getDeclarationEmitExtensionForPath(path) {
|
|
20204
20205
|
function getPossibleOriginalInputExtensionForExtension(path) {
|
20205
20206
|
return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
20206
20207
|
}
|
20208
|
+
function getPossibleOriginalInputPathWithoutChangingExt(filePath, ignoreCase, outputDir, getCommonSourceDirectory2) {
|
20209
|
+
return outputDir ? resolvePath(
|
20210
|
+
getCommonSourceDirectory2(),
|
20211
|
+
getRelativePathFromDirectory(outputDir, filePath, ignoreCase)
|
20212
|
+
) : filePath;
|
20213
|
+
}
|
20207
20214
|
function getPathsBasePath(options, host) {
|
20208
20215
|
var _a;
|
20209
20216
|
if (!options.paths) return void 0;
|
@@ -45433,7 +45440,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
45433
45440
|
mainExport = scope.contents.packageJsonContent.exports["."];
|
45434
45441
|
}
|
45435
45442
|
if (mainExport) {
|
45436
|
-
const
|
45443
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(
|
45437
45444
|
extensions,
|
45438
45445
|
state,
|
45439
45446
|
cache,
|
@@ -45443,7 +45450,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
45443
45450
|
/*isImports*/
|
45444
45451
|
false
|
45445
45452
|
);
|
45446
|
-
return
|
45453
|
+
return loadModuleFromTargetExportOrImport(
|
45447
45454
|
mainExport,
|
45448
45455
|
"",
|
45449
45456
|
/*pattern*/
|
@@ -45461,7 +45468,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
45461
45468
|
void 0
|
45462
45469
|
);
|
45463
45470
|
}
|
45464
|
-
const result =
|
45471
|
+
const result = loadModuleFromExportsOrImports(
|
45465
45472
|
extensions,
|
45466
45473
|
state,
|
45467
45474
|
cache,
|
@@ -45515,7 +45522,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
|
|
45515
45522
|
void 0
|
45516
45523
|
);
|
45517
45524
|
}
|
45518
|
-
const result =
|
45525
|
+
const result = loadModuleFromExportsOrImports(
|
45519
45526
|
extensions,
|
45520
45527
|
state,
|
45521
45528
|
cache,
|
@@ -45550,11 +45557,11 @@ function comparePatternKeys(a, b) {
|
|
45550
45557
|
if (b.length > a.length) return 1 /* GreaterThan */;
|
45551
45558
|
return 0 /* EqualTo */;
|
45552
45559
|
}
|
45553
|
-
function
|
45554
|
-
const
|
45560
|
+
function loadModuleFromExportsOrImports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
45561
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
45555
45562
|
if (!endsWith(moduleName, directorySeparator) && !moduleName.includes("*") && hasProperty(lookupTable, moduleName)) {
|
45556
45563
|
const target = lookupTable[moduleName];
|
45557
|
-
return
|
45564
|
+
return loadModuleFromTargetExportOrImport(
|
45558
45565
|
target,
|
45559
45566
|
/*subpath*/
|
45560
45567
|
"",
|
@@ -45569,7 +45576,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
45569
45576
|
const target = lookupTable[potentialTarget];
|
45570
45577
|
const starPos = potentialTarget.indexOf("*");
|
45571
45578
|
const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
45572
|
-
return
|
45579
|
+
return loadModuleFromTargetExportOrImport(
|
45573
45580
|
target,
|
45574
45581
|
subpath,
|
45575
45582
|
/*pattern*/
|
@@ -45579,7 +45586,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
45579
45586
|
} else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
45580
45587
|
const target = lookupTable[potentialTarget];
|
45581
45588
|
const subpath = moduleName.substring(potentialTarget.length - 1);
|
45582
|
-
return
|
45589
|
+
return loadModuleFromTargetExportOrImport(
|
45583
45590
|
target,
|
45584
45591
|
subpath,
|
45585
45592
|
/*pattern*/
|
@@ -45589,7 +45596,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
45589
45596
|
} else if (startsWith(moduleName, potentialTarget)) {
|
45590
45597
|
const target = lookupTable[potentialTarget];
|
45591
45598
|
const subpath = moduleName.substring(potentialTarget.length);
|
45592
|
-
return
|
45599
|
+
return loadModuleFromTargetExportOrImport(
|
45593
45600
|
target,
|
45594
45601
|
subpath,
|
45595
45602
|
/*pattern*/
|
@@ -45609,9 +45616,9 @@ function hasOneAsterisk(patternKey) {
|
|
45609
45616
|
const firstStar = patternKey.indexOf("*");
|
45610
45617
|
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
45611
45618
|
}
|
45612
|
-
function
|
45613
|
-
return
|
45614
|
-
function
|
45619
|
+
function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
45620
|
+
return loadModuleFromTargetExportOrImport;
|
45621
|
+
function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
|
45615
45622
|
if (typeof target === "string") {
|
45616
45623
|
if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
|
45617
45624
|
if (state.traceEnabled) {
|
@@ -45701,7 +45708,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
45701
45708
|
if (condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
45702
45709
|
traceIfEnabled(state, Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
45703
45710
|
const subTarget = target[condition];
|
45704
|
-
const result =
|
45711
|
+
const result = loadModuleFromTargetExportOrImport(subTarget, subpath, pattern, key);
|
45705
45712
|
if (result) {
|
45706
45713
|
traceIfEnabled(state, Diagnostics.Resolved_under_condition_0, condition);
|
45707
45714
|
traceIfEnabled(state, Diagnostics.Exiting_conditional_exports);
|
@@ -45726,7 +45733,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
45726
45733
|
);
|
45727
45734
|
}
|
45728
45735
|
for (const elem of target) {
|
45729
|
-
const result =
|
45736
|
+
const result = loadModuleFromTargetExportOrImport(elem, subpath, pattern, key);
|
45730
45737
|
if (result) {
|
45731
45738
|
return result;
|
45732
45739
|
}
|
@@ -54286,7 +54293,7 @@ function createTypeChecker(host) {
|
|
54286
54293
|
const links = getSymbolLinks(symbol);
|
54287
54294
|
const cache = links.accessibleChainCache || (links.accessibleChainCache = /* @__PURE__ */ new Map());
|
54288
54295
|
const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, ___, node) => node);
|
54289
|
-
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation
|
54296
|
+
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation ? getNodeId(firstRelevantLocation) : 0}|${meaning}`;
|
54290
54297
|
if (cache.has(key)) {
|
54291
54298
|
return cache.get(key);
|
54292
54299
|
}
|
@@ -59852,7 +59859,6 @@ function createTypeChecker(host) {
|
|
59852
59859
|
const flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0);
|
59853
59860
|
const symbol = createSymbol(flags, text);
|
59854
59861
|
symbol.links.type = getTypeFromBindingElement(e, includePatternInType, reportErrors2);
|
59855
|
-
symbol.links.bindingElement = e;
|
59856
59862
|
members.set(symbol.escapedName, symbol);
|
59857
59863
|
});
|
59858
59864
|
const result = createAnonymousType(
|
@@ -82257,7 +82263,7 @@ function createTypeChecker(host) {
|
|
82257
82263
|
});
|
82258
82264
|
}
|
82259
82265
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
82260
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
82266
|
+
const antecedent = canHaveFlowNode(expr) && expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
82261
82267
|
2 /* Start */,
|
82262
82268
|
/*node*/
|
82263
82269
|
void 0,
|
@@ -140731,6 +140737,7 @@ var ExportKind = /* @__PURE__ */ ((ExportKind3) => {
|
|
140731
140737
|
ExportKind3[ExportKind3["Default"] = 1] = "Default";
|
140732
140738
|
ExportKind3[ExportKind3["ExportEquals"] = 2] = "ExportEquals";
|
140733
140739
|
ExportKind3[ExportKind3["UMD"] = 3] = "UMD";
|
140740
|
+
ExportKind3[ExportKind3["Module"] = 4] = "Module";
|
140734
140741
|
return ExportKind3;
|
140735
140742
|
})(ExportKind || {});
|
140736
140743
|
function createCacheableExportInfoMap(host) {
|
@@ -146701,6 +146708,9 @@ function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFi
|
|
146701
146708
|
const targetSymbol = skipAlias(symbol, checker);
|
146702
146709
|
if (checker.isUnknownSymbol(targetSymbol)) {
|
146703
146710
|
importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor((_a = symbol.declarations) == null ? void 0 : _a[0], isAnyImportOrRequireStatement)));
|
146711
|
+
} else if (targetSymbol.parent === void 0) {
|
146712
|
+
Debug.assert(declaration !== void 0, "expected module symbol to have a declaration");
|
146713
|
+
importAdder.addImportForModuleSymbol(symbol, isValidTypeOnlyUseSite, declaration);
|
146704
146714
|
} else {
|
146705
146715
|
importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
|
146706
146716
|
}
|
@@ -156919,7 +156929,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
156919
156929
|
const removeExisting = /* @__PURE__ */ new Set();
|
156920
156930
|
const verbatimImports = /* @__PURE__ */ new Set();
|
156921
156931
|
const newImports = /* @__PURE__ */ new Map();
|
156922
|
-
return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes, hasFixes, addImportForUnresolvedIdentifier, addImportForNonExistentExport, removeExistingImport, addVerbatimImport };
|
156932
|
+
return { addImportFromDiagnostic, addImportFromExportedSymbol, addImportForModuleSymbol, writeFixes, hasFixes, addImportForUnresolvedIdentifier, addImportForNonExistentExport, removeExistingImport, addVerbatimImport };
|
156923
156933
|
function addVerbatimImport(declaration) {
|
156924
156934
|
verbatimImports.add(declaration);
|
156925
156935
|
}
|
@@ -156935,7 +156945,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
156935
156945
|
}
|
156936
156946
|
function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite, referenceImport) {
|
156937
156947
|
var _a, _b;
|
156938
|
-
const moduleSymbol = Debug.checkDefined(exportedSymbol.parent);
|
156948
|
+
const moduleSymbol = Debug.checkDefined(exportedSymbol.parent, "Expected exported symbol to have module symbol as parent");
|
156939
156949
|
const symbolName2 = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions));
|
156940
156950
|
const checker = program.getTypeChecker();
|
156941
156951
|
const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker));
|
@@ -156985,6 +156995,75 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
156985
156995
|
addImport({ fix, symbolName: localName ?? symbolName2, errorIdentifierText: void 0 });
|
156986
156996
|
}
|
156987
156997
|
}
|
156998
|
+
function addImportForModuleSymbol(symbolAlias, isValidTypeOnlyUseSite, referenceImport) {
|
156999
|
+
var _a, _b, _c;
|
157000
|
+
const checker = program.getTypeChecker();
|
157001
|
+
const moduleSymbol = checker.getAliasedSymbol(symbolAlias);
|
157002
|
+
Debug.assert(moduleSymbol.flags & 1536 /* Module */, "Expected symbol to be a module");
|
157003
|
+
const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
|
157004
|
+
const moduleSpecifierResult = ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
|
157005
|
+
moduleSymbol,
|
157006
|
+
checker,
|
157007
|
+
compilerOptions,
|
157008
|
+
sourceFile,
|
157009
|
+
moduleSpecifierResolutionHost,
|
157010
|
+
preferences,
|
157011
|
+
/*options*/
|
157012
|
+
void 0,
|
157013
|
+
/*forAutoImport*/
|
157014
|
+
true
|
157015
|
+
);
|
157016
|
+
const useRequire = shouldUseRequire(sourceFile, program);
|
157017
|
+
let addAsTypeOnly = getAddAsTypeOnly(
|
157018
|
+
isValidTypeOnlyUseSite,
|
157019
|
+
/*isForNewImportDeclaration*/
|
157020
|
+
true,
|
157021
|
+
/*symbol*/
|
157022
|
+
void 0,
|
157023
|
+
symbolAlias.flags,
|
157024
|
+
program.getTypeChecker(),
|
157025
|
+
compilerOptions
|
157026
|
+
);
|
157027
|
+
addAsTypeOnly = addAsTypeOnly === 1 /* Allowed */ && isTypeOnlyImportDeclaration(referenceImport) ? 2 /* Required */ : 1 /* Allowed */;
|
157028
|
+
const importKind = isImportDeclaration(referenceImport) ? isDefaultImport(referenceImport) ? 1 /* Default */ : 2 /* Namespace */ : isImportSpecifier(referenceImport) ? 0 /* Named */ : isImportClause(referenceImport) && !!referenceImport.name ? 1 /* Default */ : 2 /* Namespace */;
|
157029
|
+
const exportInfo = [{
|
157030
|
+
symbol: symbolAlias,
|
157031
|
+
moduleSymbol,
|
157032
|
+
moduleFileName: (_c = (_b = (_a = moduleSymbol.declarations) == null ? void 0 : _a[0]) == null ? void 0 : _b.getSourceFile()) == null ? void 0 : _c.fileName,
|
157033
|
+
exportKind: 4 /* Module */,
|
157034
|
+
targetFlags: symbolAlias.flags,
|
157035
|
+
isFromPackageJson: false
|
157036
|
+
}];
|
157037
|
+
const existingFix = getImportFixForSymbol(
|
157038
|
+
sourceFile,
|
157039
|
+
exportInfo,
|
157040
|
+
program,
|
157041
|
+
/*position*/
|
157042
|
+
void 0,
|
157043
|
+
!!isValidTypeOnlyUseSite,
|
157044
|
+
useRequire,
|
157045
|
+
host,
|
157046
|
+
preferences
|
157047
|
+
);
|
157048
|
+
let fix;
|
157049
|
+
if (existingFix && importKind !== 2 /* Namespace */) {
|
157050
|
+
fix = {
|
157051
|
+
...existingFix,
|
157052
|
+
addAsTypeOnly,
|
157053
|
+
importKind
|
157054
|
+
};
|
157055
|
+
} else {
|
157056
|
+
fix = {
|
157057
|
+
kind: 3 /* AddNew */,
|
157058
|
+
moduleSpecifierKind: existingFix !== void 0 ? existingFix.moduleSpecifierKind : moduleSpecifierResult.kind,
|
157059
|
+
moduleSpecifier: existingFix !== void 0 ? existingFix.moduleSpecifier : first(moduleSpecifierResult.moduleSpecifiers),
|
157060
|
+
importKind,
|
157061
|
+
addAsTypeOnly,
|
157062
|
+
useRequire
|
157063
|
+
};
|
157064
|
+
}
|
157065
|
+
addImport({ fix, symbolName: symbolAlias.name, errorIdentifierText: void 0 });
|
157066
|
+
}
|
156988
157067
|
function addImportForNonExistentExport(exportName, exportingFileName, exportKind, exportedMeanings, isImportUsageValidAsTypeOnly) {
|
156989
157068
|
const exportingSourceFile = program.getSourceFile(exportingFileName);
|
156990
157069
|
const useRequire = shouldUseRequire(sourceFile, program);
|
@@ -157433,7 +157512,8 @@ function getAllExportInfoForSymbol(importingFile, symbol, symbolName2, moduleSym
|
|
157433
157512
|
const moduleSourceFile = isFileExcluded && mergedModuleSymbol.declarations && getDeclarationOfKind(mergedModuleSymbol, 307 /* SourceFile */);
|
157434
157513
|
const moduleSymbolExcluded = moduleSourceFile && isFileExcluded(moduleSourceFile);
|
157435
157514
|
return getExportInfoMap(importingFile, host, program, preferences, cancellationToken).search(importingFile.path, preferCapitalized, (name) => name === symbolName2, (info) => {
|
157436
|
-
|
157515
|
+
const checker = getChecker(info[0].isFromPackageJson);
|
157516
|
+
if (checker.getMergedSymbol(skipAlias(info[0].symbol, checker)) === symbol && (moduleSymbolExcluded || info.some((i) => checker.getMergedSymbol(i.moduleSymbol) === moduleSymbol || i.symbol.parent === moduleSymbol))) {
|
157437
157517
|
return info;
|
157438
157518
|
}
|
157439
157519
|
});
|
@@ -157862,6 +157942,8 @@ function getImportKind(importingFile, exportKind, program, forceImportKeyword) {
|
|
157862
157942
|
return getExportEqualsImportKind(importingFile, program.getCompilerOptions(), !!forceImportKeyword);
|
157863
157943
|
case 3 /* UMD */:
|
157864
157944
|
return getUmdImportKind(importingFile, program, !!forceImportKeyword);
|
157945
|
+
case 4 /* Module */:
|
157946
|
+
return 2 /* Namespace */;
|
157865
157947
|
default:
|
157866
157948
|
return Debug.assertNever(exportKind);
|
157867
157949
|
}
|
@@ -169387,7 +169469,7 @@ function createNameAndKindSet() {
|
|
169387
169469
|
}
|
169388
169470
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences, includeSymbol) {
|
169389
169471
|
if (isInReferenceComment(sourceFile, position)) {
|
169390
|
-
const entries = getTripleSlashReferenceCompletion(sourceFile, position, program, host);
|
169472
|
+
const entries = getTripleSlashReferenceCompletion(sourceFile, position, program, host, createModuleSpecifierResolutionHost(program, host));
|
169391
169473
|
return entries && convertPathCompletions(entries);
|
169392
169474
|
}
|
169393
169475
|
if (isInString(sourceFile, position, contextToken)) {
|
@@ -169731,8 +169813,9 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, prog
|
|
169731
169813
|
const scriptDirectory = getDirectoryPath(scriptPath);
|
169732
169814
|
const compilerOptions = program.getCompilerOptions();
|
169733
169815
|
const typeChecker = program.getTypeChecker();
|
169816
|
+
const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
|
169734
169817
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
169735
|
-
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, program, host, extensionOptions);
|
169818
|
+
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, moduleSpecifierResolutionHost, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, program, host, moduleSpecifierResolutionHost, extensionOptions);
|
169736
169819
|
}
|
169737
169820
|
function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile, typeChecker, preferences, resolutionMode) {
|
169738
169821
|
return {
|
@@ -169743,7 +169826,7 @@ function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile
|
|
169743
169826
|
resolutionMode
|
169744
169827
|
};
|
169745
169828
|
}
|
169746
|
-
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) {
|
169829
|
+
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, moduleSpecifierResolutionHost, scriptPath, extensionOptions) {
|
169747
169830
|
const compilerOptions = program.getCompilerOptions();
|
169748
169831
|
if (compilerOptions.rootDirs) {
|
169749
169832
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(
|
@@ -169753,6 +169836,7 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
169753
169836
|
extensionOptions,
|
169754
169837
|
program,
|
169755
169838
|
host,
|
169839
|
+
moduleSpecifierResolutionHost,
|
169756
169840
|
scriptPath
|
169757
169841
|
);
|
169758
169842
|
} else {
|
@@ -169762,6 +169846,7 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
169762
169846
|
extensionOptions,
|
169763
169847
|
program,
|
169764
169848
|
host,
|
169849
|
+
moduleSpecifierResolutionHost,
|
169765
169850
|
/*moduleSpecifierIsRelative*/
|
169766
169851
|
true,
|
169767
169852
|
scriptPath
|
@@ -169787,7 +169872,7 @@ function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ign
|
|
169787
169872
|
compareStringsCaseSensitive
|
169788
169873
|
);
|
169789
169874
|
}
|
169790
|
-
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, program, host, exclude) {
|
169875
|
+
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, exclude) {
|
169791
169876
|
const compilerOptions = program.getCompilerOptions();
|
169792
169877
|
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
169793
169878
|
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
@@ -169799,6 +169884,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
169799
169884
|
extensionOptions,
|
169800
169885
|
program,
|
169801
169886
|
host,
|
169887
|
+
moduleSpecifierResolutionHost,
|
169802
169888
|
/*moduleSpecifierIsRelative*/
|
169803
169889
|
true,
|
169804
169890
|
exclude
|
@@ -169806,7 +169892,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
169806
169892
|
(itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
|
169807
169893
|
);
|
169808
169894
|
}
|
169809
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
169895
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
169810
169896
|
var _a;
|
169811
169897
|
if (fragment === void 0) {
|
169812
169898
|
fragment = "";
|
@@ -169831,7 +169917,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
169831
169917
|
if (versionPaths) {
|
169832
169918
|
const packageDirectory = getDirectoryPath(packageJsonPath);
|
169833
169919
|
const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
|
169834
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, program, host, versionPaths)) {
|
169920
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, versionPaths)) {
|
169835
169921
|
return result;
|
169836
169922
|
}
|
169837
169923
|
}
|
@@ -169859,7 +169945,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
169859
169945
|
getBaseFileName(filePath),
|
169860
169946
|
program,
|
169861
169947
|
extensionOptions,
|
169862
|
-
/*
|
169948
|
+
/*isExportsOrImportsWildcard*/
|
169863
169949
|
false
|
169864
169950
|
);
|
169865
169951
|
result.add(nameAndKind(name, "script" /* scriptElement */, extension));
|
@@ -169876,7 +169962,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
169876
169962
|
}
|
169877
169963
|
return result;
|
169878
169964
|
}
|
169879
|
-
function getFilenameWithExtensionOption(name, program, extensionOptions,
|
169965
|
+
function getFilenameWithExtensionOption(name, program, extensionOptions, isExportsOrImportsWildcard) {
|
169880
169966
|
const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
|
169881
169967
|
if (nonJsResult) {
|
169882
169968
|
return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
|
@@ -169890,7 +169976,7 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
169890
169976
|
program.getCompilerOptions(),
|
169891
169977
|
extensionOptions.importingSourceFile
|
169892
169978
|
).getAllowedEndingsInPreferredOrder(extensionOptions.resolutionMode);
|
169893
|
-
if (
|
169979
|
+
if (isExportsOrImportsWildcard) {
|
169894
169980
|
allowedEndings = allowedEndings.filter((e) => e !== 0 /* Minimal */ && e !== 1 /* Index */);
|
169895
169981
|
}
|
169896
169982
|
if (allowedEndings[0] === 3 /* TsExtension */) {
|
@@ -169900,13 +169986,13 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
169900
169986
|
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
|
169901
169987
|
return outputExtension2 ? { name: changeExtension(name, outputExtension2), extension: outputExtension2 } : { name, extension: tryGetExtensionFromPath2(name) };
|
169902
169988
|
}
|
169903
|
-
if (!
|
169989
|
+
if (!isExportsOrImportsWildcard && (allowedEndings[0] === 0 /* Minimal */ || allowedEndings[0] === 1 /* Index */) && fileExtensionIsOneOf(name, [".js" /* Js */, ".jsx" /* Jsx */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */])) {
|
169904
169990
|
return { name: removeFileExtension(name), extension: tryGetExtensionFromPath2(name) };
|
169905
169991
|
}
|
169906
169992
|
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
|
169907
169993
|
return outputExtension ? { name: changeExtension(name, outputExtension), extension: outputExtension } : { name, extension: tryGetExtensionFromPath2(name) };
|
169908
169994
|
}
|
169909
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, program, host, paths) {
|
169995
|
+
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, paths) {
|
169910
169996
|
const getPatternsForKey = (key) => paths[key];
|
169911
169997
|
const comparePaths2 = (a, b) => {
|
169912
169998
|
const patternA = tryParsePattern(a);
|
@@ -169915,40 +170001,43 @@ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensio
|
|
169915
170001
|
const lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
|
169916
170002
|
return compareValues(lengthB, lengthA);
|
169917
170003
|
};
|
169918
|
-
return
|
170004
|
+
return addCompletionEntriesFromPathsOrExportsOrImports(
|
169919
170005
|
result,
|
169920
170006
|
/*isExports*/
|
169921
170007
|
false,
|
170008
|
+
/*isImports*/
|
170009
|
+
false,
|
169922
170010
|
fragment,
|
169923
170011
|
baseDirectory,
|
169924
170012
|
extensionOptions,
|
169925
170013
|
program,
|
169926
170014
|
host,
|
170015
|
+
moduleSpecifierResolutionHost,
|
169927
170016
|
getOwnKeys(paths),
|
169928
170017
|
getPatternsForKey,
|
169929
170018
|
comparePaths2
|
169930
170019
|
);
|
169931
170020
|
}
|
169932
|
-
function
|
170021
|
+
function addCompletionEntriesFromPathsOrExportsOrImports(result, isExports, isImports, fragment, baseDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, keys, getPatternsForKey, comparePaths2) {
|
169933
170022
|
let pathResults = [];
|
169934
170023
|
let matchedPath;
|
169935
170024
|
for (const key of keys) {
|
169936
170025
|
if (key === ".") continue;
|
169937
|
-
const keyWithoutLeadingDotSlash = key.replace(/^\.\//, "");
|
170026
|
+
const keyWithoutLeadingDotSlash = key.replace(/^\.\//, "") + ((isExports || isImports) && endsWith(key, "/") ? "*" : "");
|
169938
170027
|
const patterns = getPatternsForKey(key);
|
169939
170028
|
if (patterns) {
|
169940
170029
|
const pathPattern = tryParsePattern(keyWithoutLeadingDotSlash);
|
169941
170030
|
if (!pathPattern) continue;
|
169942
170031
|
const isMatch = typeof pathPattern === "object" && isPatternMatch(pathPattern, fragment);
|
169943
|
-
const isLongestMatch = isMatch && (matchedPath === void 0 || comparePaths2(
|
170032
|
+
const isLongestMatch = isMatch && (matchedPath === void 0 || comparePaths2(keyWithoutLeadingDotSlash, matchedPath) === -1 /* LessThan */);
|
169944
170033
|
if (isLongestMatch) {
|
169945
|
-
matchedPath =
|
170034
|
+
matchedPath = keyWithoutLeadingDotSlash;
|
169946
170035
|
pathResults = pathResults.filter((r) => !r.matchedPattern);
|
169947
170036
|
}
|
169948
|
-
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(
|
170037
|
+
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(keyWithoutLeadingDotSlash, matchedPath) !== 1 /* GreaterThan */) {
|
169949
170038
|
pathResults.push({
|
169950
170039
|
matchedPattern: isMatch,
|
169951
|
-
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports
|
170040
|
+
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost).map(({ name, kind, extension }) => nameAndKind(name, kind, extension))
|
169952
170041
|
});
|
169953
170042
|
}
|
169954
170043
|
}
|
@@ -169956,7 +170045,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
169956
170045
|
pathResults.forEach((pathResult) => pathResult.results.forEach((r) => result.add(r)));
|
169957
170046
|
return matchedPath !== void 0;
|
169958
170047
|
}
|
169959
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, program, host, extensionOptions) {
|
170048
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, program, host, moduleSpecifierResolutionHost, extensionOptions) {
|
169960
170049
|
const typeChecker = program.getTypeChecker();
|
169961
170050
|
const compilerOptions = program.getCompilerOptions();
|
169962
170051
|
const { baseUrl, paths } = compilerOptions;
|
@@ -169970,6 +170059,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
169970
170059
|
extensionOptions,
|
169971
170060
|
program,
|
169972
170061
|
host,
|
170062
|
+
moduleSpecifierResolutionHost,
|
169973
170063
|
/*moduleSpecifierIsRelative*/
|
169974
170064
|
false,
|
169975
170065
|
/*exclude*/
|
@@ -169979,7 +170069,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
169979
170069
|
}
|
169980
170070
|
if (paths) {
|
169981
170071
|
const absolute = getPathsBasePath(compilerOptions, host);
|
169982
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, program, host, paths);
|
170072
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, program, host, moduleSpecifierResolutionHost, paths);
|
169983
170073
|
}
|
169984
170074
|
const fragmentDirectory = getFragmentDirectory(fragment);
|
169985
170075
|
for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
|
@@ -169990,7 +170080,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
169990
170080
|
void 0
|
169991
170081
|
));
|
169992
170082
|
}
|
169993
|
-
getCompletionEntriesFromTypings(host,
|
170083
|
+
getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, fragmentDirectory, extensionOptions, result);
|
169994
170084
|
if (moduleResolutionUsesNodeModules(moduleResolution)) {
|
169995
170085
|
let foundGlobal = false;
|
169996
170086
|
if (fragmentDirectory === void 0) {
|
@@ -170008,6 +170098,26 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
170008
170098
|
}
|
170009
170099
|
}
|
170010
170100
|
if (!foundGlobal) {
|
170101
|
+
const resolvePackageJsonExports = getResolvePackageJsonExports(compilerOptions);
|
170102
|
+
const resolvePackageJsonImports = getResolvePackageJsonImports(compilerOptions);
|
170103
|
+
let seenPackageScope = false;
|
170104
|
+
const importsLookup = (directory) => {
|
170105
|
+
if (resolvePackageJsonImports && !seenPackageScope) {
|
170106
|
+
const packageFile = combinePaths(directory, "package.json");
|
170107
|
+
if (seenPackageScope = tryFileExists(host, packageFile)) {
|
170108
|
+
const packageJson = readJson(packageFile, host);
|
170109
|
+
exportsOrImportsLookup(
|
170110
|
+
packageJson.imports,
|
170111
|
+
fragment,
|
170112
|
+
directory,
|
170113
|
+
/*isExports*/
|
170114
|
+
false,
|
170115
|
+
/*isImports*/
|
170116
|
+
true
|
170117
|
+
);
|
170118
|
+
}
|
170119
|
+
}
|
170120
|
+
};
|
170011
170121
|
let ancestorLookup = (ancestor) => {
|
170012
170122
|
const nodeModules = combinePaths(ancestor, "node_modules");
|
170013
170123
|
if (tryDirectoryExists(host, nodeModules)) {
|
@@ -170017,6 +170127,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
170017
170127
|
extensionOptions,
|
170018
170128
|
program,
|
170019
170129
|
host,
|
170130
|
+
moduleSpecifierResolutionHost,
|
170020
170131
|
/*moduleSpecifierIsRelative*/
|
170021
170132
|
false,
|
170022
170133
|
/*exclude*/
|
@@ -170024,58 +170135,77 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
170024
170135
|
result
|
170025
170136
|
);
|
170026
170137
|
}
|
170138
|
+
importsLookup(ancestor);
|
170027
170139
|
};
|
170028
|
-
if (fragmentDirectory &&
|
170029
|
-
const
|
170140
|
+
if (fragmentDirectory && resolvePackageJsonExports) {
|
170141
|
+
const nodeModulesDirectoryOrImportsLookup = ancestorLookup;
|
170030
170142
|
ancestorLookup = (ancestor) => {
|
170031
170143
|
const components = getPathComponents(fragment);
|
170032
170144
|
components.shift();
|
170033
170145
|
let packagePath = components.shift();
|
170034
170146
|
if (!packagePath) {
|
170035
|
-
return
|
170147
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
170036
170148
|
}
|
170037
170149
|
if (startsWith(packagePath, "@")) {
|
170038
170150
|
const subName = components.shift();
|
170039
170151
|
if (!subName) {
|
170040
|
-
return
|
170152
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
170041
170153
|
}
|
170042
170154
|
packagePath = combinePaths(packagePath, subName);
|
170043
170155
|
}
|
170156
|
+
if (resolvePackageJsonImports && startsWith(packagePath, "#")) {
|
170157
|
+
return importsLookup(ancestor);
|
170158
|
+
}
|
170044
170159
|
const packageDirectory = combinePaths(ancestor, "node_modules", packagePath);
|
170045
170160
|
const packageFile = combinePaths(packageDirectory, "package.json");
|
170046
170161
|
if (tryFileExists(host, packageFile)) {
|
170047
170162
|
const packageJson = readJson(packageFile, host);
|
170048
|
-
const
|
170049
|
-
|
170050
|
-
|
170051
|
-
|
170052
|
-
|
170053
|
-
|
170054
|
-
|
170055
|
-
|
170056
|
-
|
170057
|
-
|
170058
|
-
|
170059
|
-
true,
|
170060
|
-
fragmentSubpath,
|
170061
|
-
packageDirectory,
|
170062
|
-
extensionOptions,
|
170063
|
-
program,
|
170064
|
-
host,
|
170065
|
-
keys,
|
170066
|
-
(key) => singleElementArray(getPatternFromFirstMatchingCondition(exports2[key], conditions)),
|
170067
|
-
comparePatternKeys
|
170068
|
-
);
|
170069
|
-
return;
|
170070
|
-
}
|
170163
|
+
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
170164
|
+
exportsOrImportsLookup(
|
170165
|
+
packageJson.exports,
|
170166
|
+
fragmentSubpath,
|
170167
|
+
packageDirectory,
|
170168
|
+
/*isExports*/
|
170169
|
+
true,
|
170170
|
+
/*isImports*/
|
170171
|
+
false
|
170172
|
+
);
|
170173
|
+
return;
|
170071
170174
|
}
|
170072
|
-
return
|
170175
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
170073
170176
|
};
|
170074
170177
|
}
|
170075
170178
|
forEachAncestorDirectoryStoppingAtGlobalCache(host, scriptPath, ancestorLookup);
|
170076
170179
|
}
|
170077
170180
|
}
|
170078
170181
|
return arrayFrom(result.values());
|
170182
|
+
function exportsOrImportsLookup(lookupTable, fragment2, baseDirectory, isExports, isImports) {
|
170183
|
+
if (typeof lookupTable !== "object" || lookupTable === null) {
|
170184
|
+
return;
|
170185
|
+
}
|
170186
|
+
const keys = getOwnKeys(lookupTable);
|
170187
|
+
const conditions = getConditions(compilerOptions, mode);
|
170188
|
+
addCompletionEntriesFromPathsOrExportsOrImports(
|
170189
|
+
result,
|
170190
|
+
isExports,
|
170191
|
+
isImports,
|
170192
|
+
fragment2,
|
170193
|
+
baseDirectory,
|
170194
|
+
extensionOptions,
|
170195
|
+
program,
|
170196
|
+
host,
|
170197
|
+
moduleSpecifierResolutionHost,
|
170198
|
+
keys,
|
170199
|
+
(key) => {
|
170200
|
+
const pattern = getPatternFromFirstMatchingCondition(lookupTable[key], conditions);
|
170201
|
+
if (pattern === void 0) {
|
170202
|
+
return void 0;
|
170203
|
+
}
|
170204
|
+
return singleElementArray(endsWith(key, "/") && endsWith(pattern, "/") ? pattern + "*" : pattern);
|
170205
|
+
},
|
170206
|
+
comparePatternKeys
|
170207
|
+
);
|
170208
|
+
}
|
170079
170209
|
}
|
170080
170210
|
function getPatternFromFirstMatchingCondition(target, conditions) {
|
170081
170211
|
if (typeof target === "string") {
|
@@ -170093,25 +170223,28 @@ function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
170093
170223
|
function getFragmentDirectory(fragment) {
|
170094
170224
|
return containsSlash(fragment) ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
170095
170225
|
}
|
170096
|
-
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions,
|
170097
|
-
|
170098
|
-
|
170226
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost) {
|
170227
|
+
const parsedPath = tryParsePattern(path);
|
170228
|
+
if (!parsedPath) {
|
170229
|
+
return emptyArray;
|
170099
170230
|
}
|
170100
|
-
|
170101
|
-
|
170231
|
+
if (typeof parsedPath === "string") {
|
170232
|
+
return justPathMappingName(path, "script" /* scriptElement */);
|
170233
|
+
}
|
170234
|
+
const remainingFragment = tryRemovePrefix(fragment, parsedPath.prefix);
|
170102
170235
|
if (remainingFragment === void 0) {
|
170103
|
-
const starIsFullPathComponent = path
|
170104
|
-
return starIsFullPathComponent ? justPathMappingName(
|
170236
|
+
const starIsFullPathComponent = endsWith(path, "/*");
|
170237
|
+
return starIsFullPathComponent ? justPathMappingName(parsedPath.prefix, "directory" /* directory */) : flatMap(patterns, (pattern) => {
|
170105
170238
|
var _a;
|
170106
|
-
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions,
|
170239
|
+
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost)) == null ? void 0 : _a.map(({ name, ...rest }) => ({ name: parsedPath.prefix + name + parsedPath.suffix, ...rest }));
|
170107
170240
|
});
|
170108
170241
|
}
|
170109
|
-
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions,
|
170242
|
+
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost));
|
170110
170243
|
function justPathMappingName(name, kind) {
|
170111
170244
|
return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: void 0 }] : emptyArray;
|
170112
170245
|
}
|
170113
170246
|
}
|
170114
|
-
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions,
|
170247
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost) {
|
170115
170248
|
if (!host.readDirectory) {
|
170116
170249
|
return void 0;
|
170117
170250
|
}
|
@@ -170124,35 +170257,67 @@ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensio
|
|
170124
170257
|
const normalizedPrefixBase = hasTrailingDirectorySeparator(parsed.prefix) ? "" : getBaseFileName(normalizedPrefix);
|
170125
170258
|
const fragmentHasPath = containsSlash(fragment);
|
170126
170259
|
const fragmentDirectory = fragmentHasPath ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
170260
|
+
const getCommonSourceDirectory2 = () => moduleSpecifierResolutionHost.getCommonSourceDirectory();
|
170261
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(moduleSpecifierResolutionHost);
|
170262
|
+
const outDir = program.getCompilerOptions().outDir;
|
170263
|
+
const declarationDir = program.getCompilerOptions().declarationDir;
|
170127
170264
|
const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
|
170265
|
+
const baseDirectory = normalizePath(combinePaths(packageDirectory, expandedPrefixDirectory));
|
170266
|
+
const possibleInputBaseDirectoryForOutDir = isImports && outDir && getPossibleOriginalInputPathWithoutChangingExt(baseDirectory, ignoreCase, outDir, getCommonSourceDirectory2);
|
170267
|
+
const possibleInputBaseDirectoryForDeclarationDir = isImports && declarationDir && getPossibleOriginalInputPathWithoutChangingExt(baseDirectory, ignoreCase, declarationDir, getCommonSourceDirectory2);
|
170128
170268
|
const normalizedSuffix = normalizePath(parsed.suffix);
|
170129
170269
|
const declarationExtension = normalizedSuffix && getDeclarationEmitExtensionForPath("_" + normalizedSuffix);
|
170130
|
-
const
|
170131
|
-
const
|
170132
|
-
|
170270
|
+
const inputExtension = normalizedSuffix ? getPossibleOriginalInputExtensionForExtension("_" + normalizedSuffix) : void 0;
|
170271
|
+
const matchingSuffixes = [
|
170272
|
+
declarationExtension && changeExtension(normalizedSuffix, declarationExtension),
|
170273
|
+
...inputExtension ? inputExtension.map((ext) => changeExtension(normalizedSuffix, ext)) : [],
|
170274
|
+
normalizedSuffix
|
170275
|
+
].filter(isString);
|
170133
170276
|
const includeGlobs = normalizedSuffix ? matchingSuffixes.map((suffix) => "**/*" + suffix) : ["./*"];
|
170134
|
-
const
|
170135
|
-
|
170136
|
-
|
170137
|
-
|
170138
|
-
|
170139
|
-
|
170140
|
-
|
170141
|
-
|
170142
|
-
|
170143
|
-
|
170144
|
-
|
170145
|
-
|
170146
|
-
}
|
170147
|
-
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, program, extensionOptions, isExportsWildcard);
|
170148
|
-
return nameAndKind(name, "script" /* scriptElement */, extension);
|
170277
|
+
const isExportsOrImportsWildcard = (isExports || isImports) && endsWith(pattern, "/*");
|
170278
|
+
let matches = getMatchesWithPrefix(baseDirectory);
|
170279
|
+
if (possibleInputBaseDirectoryForOutDir) {
|
170280
|
+
matches = concatenate(matches, getMatchesWithPrefix(possibleInputBaseDirectoryForOutDir));
|
170281
|
+
}
|
170282
|
+
if (possibleInputBaseDirectoryForDeclarationDir) {
|
170283
|
+
matches = concatenate(matches, getMatchesWithPrefix(possibleInputBaseDirectoryForDeclarationDir));
|
170284
|
+
}
|
170285
|
+
if (!normalizedSuffix) {
|
170286
|
+
matches = concatenate(matches, getDirectoryMatches(baseDirectory));
|
170287
|
+
if (possibleInputBaseDirectoryForOutDir) {
|
170288
|
+
matches = concatenate(matches, getDirectoryMatches(possibleInputBaseDirectoryForOutDir));
|
170149
170289
|
}
|
170150
|
-
|
170151
|
-
|
170152
|
-
|
170153
|
-
|
170290
|
+
if (possibleInputBaseDirectoryForDeclarationDir) {
|
170291
|
+
matches = concatenate(matches, getDirectoryMatches(possibleInputBaseDirectoryForDeclarationDir));
|
170292
|
+
}
|
170293
|
+
}
|
170294
|
+
return matches;
|
170295
|
+
function getMatchesWithPrefix(directory) {
|
170296
|
+
const completePrefix = fragmentHasPath ? directory : ensureTrailingDirectorySeparator(directory) + normalizedPrefixBase;
|
170297
|
+
return mapDefined(tryReadDirectory(
|
170298
|
+
host,
|
170299
|
+
directory,
|
170300
|
+
extensionOptions.extensionsToSearch,
|
170301
|
+
/*exclude*/
|
170302
|
+
void 0,
|
170303
|
+
includeGlobs
|
170304
|
+
), (match) => {
|
170305
|
+
const trimmedWithPattern = trimPrefixAndSuffix(match, completePrefix);
|
170306
|
+
if (trimmedWithPattern) {
|
170307
|
+
if (containsSlash(trimmedWithPattern)) {
|
170308
|
+
return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
170309
|
+
}
|
170310
|
+
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, program, extensionOptions, isExportsOrImportsWildcard);
|
170311
|
+
return nameAndKind(name, "script" /* scriptElement */, extension);
|
170312
|
+
}
|
170313
|
+
});
|
170314
|
+
}
|
170315
|
+
function getDirectoryMatches(directoryName) {
|
170316
|
+
return mapDefined(tryGetDirectories(host, directoryName), (dir) => dir === "node_modules" ? void 0 : directoryResult(dir));
|
170317
|
+
}
|
170318
|
+
function trimPrefixAndSuffix(path, prefix) {
|
170154
170319
|
return firstDefined(matchingSuffixes, (suffix) => {
|
170155
|
-
const inner = withoutStartAndEnd(normalizePath(path),
|
170320
|
+
const inner = withoutStartAndEnd(normalizePath(path), prefix, suffix);
|
170156
170321
|
return inner === void 0 ? void 0 : removeLeadingDirectorySeparator(inner);
|
170157
170322
|
});
|
170158
170323
|
}
|
@@ -170172,7 +170337,7 @@ function getAmbientModuleCompletions(fragment, fragmentDirectory, checker) {
|
|
170172
170337
|
}
|
170173
170338
|
return nonRelativeModuleNames;
|
170174
170339
|
}
|
170175
|
-
function getTripleSlashReferenceCompletion(sourceFile, position, program, host) {
|
170340
|
+
function getTripleSlashReferenceCompletion(sourceFile, position, program, host, moduleSpecifierResolutionHost) {
|
170176
170341
|
const compilerOptions = program.getCompilerOptions();
|
170177
170342
|
const token = getTokenAtPosition(sourceFile, position);
|
170178
170343
|
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
@@ -170193,13 +170358,14 @@ function getTripleSlashReferenceCompletion(sourceFile, position, program, host)
|
|
170193
170358
|
getExtensionOptions(compilerOptions, 0 /* Filename */, sourceFile),
|
170194
170359
|
program,
|
170195
170360
|
host,
|
170361
|
+
moduleSpecifierResolutionHost,
|
170196
170362
|
/*moduleSpecifierIsRelative*/
|
170197
170363
|
true,
|
170198
170364
|
sourceFile.path
|
170199
|
-
) : kind === "types" ? getCompletionEntriesFromTypings(host,
|
170365
|
+
) : kind === "types" ? getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
|
170200
170366
|
return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
|
170201
170367
|
}
|
170202
|
-
function getCompletionEntriesFromTypings(host,
|
170368
|
+
function getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
|
170203
170369
|
const options = program.getCompilerOptions();
|
170204
170370
|
const seen = /* @__PURE__ */ new Map();
|
170205
170371
|
const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
|
@@ -170236,6 +170402,7 @@ function getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDire
|
|
170236
170402
|
extensionOptions,
|
170237
170403
|
program,
|
170238
170404
|
host,
|
170405
|
+
moduleSpecifierResolutionHost,
|
170239
170406
|
/*moduleSpecifierIsRelative*/
|
170240
170407
|
false,
|
170241
170408
|
/*exclude*/
|
@@ -182434,6 +182601,7 @@ __export(ts_exports2, {
|
|
182434
182601
|
getPositionOfLineAndCharacter: () => getPositionOfLineAndCharacter,
|
182435
182602
|
getPossibleGenericSignatures: () => getPossibleGenericSignatures,
|
182436
182603
|
getPossibleOriginalInputExtensionForExtension: () => getPossibleOriginalInputExtensionForExtension,
|
182604
|
+
getPossibleOriginalInputPathWithoutChangingExt: () => getPossibleOriginalInputPathWithoutChangingExt,
|
182437
182605
|
getPossibleTypeArgumentsInfo: () => getPossibleTypeArgumentsInfo,
|
182438
182606
|
getPreEmitDiagnostics: () => getPreEmitDiagnostics,
|
182439
182607
|
getPrecedingNonSpaceCharacterPosition: () => getPrecedingNonSpaceCharacterPosition,
|
@@ -197179,6 +197347,7 @@ if (typeof console !== "undefined") {
|
|
197179
197347
|
getPositionOfLineAndCharacter,
|
197180
197348
|
getPossibleGenericSignatures,
|
197181
197349
|
getPossibleOriginalInputExtensionForExtension,
|
197350
|
+
getPossibleOriginalInputPathWithoutChangingExt,
|
197182
197351
|
getPossibleTypeArgumentsInfo,
|
197183
197352
|
getPreEmitDiagnostics,
|
197184
197353
|
getPrecedingNonSpaceCharacterPosition,
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "typescript",
|
3
3
|
"author": "Microsoft Corp.",
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
5
|
-
"version": "5.7.0-dev.
|
5
|
+
"version": "5.7.0-dev.20241101",
|
6
6
|
"license": "Apache-2.0",
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
8
8
|
"keywords": [
|
@@ -116,5 +116,5 @@
|
|
116
116
|
"node": "20.1.0",
|
117
117
|
"npm": "8.19.4"
|
118
118
|
},
|
119
|
-
"gitHead": "
|
119
|
+
"gitHead": "3e6171833e6d8481626b56a7de09ea03092fadf2"
|
120
120
|
}
|