typescript 4.5.0-dev.20211001 → 4.5.0-dev.20211002
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/de/diagnosticMessages.generated.json +4 -4
- package/lib/es/diagnosticMessages.generated.json +4 -4
- package/lib/it/diagnosticMessages.generated.json +4 -4
- package/lib/ja/diagnosticMessages.generated.json +4 -4
- package/lib/ko/diagnosticMessages.generated.json +4 -4
- package/lib/pl/diagnosticMessages.generated.json +4 -4
- package/lib/pt-br/diagnosticMessages.generated.json +4 -4
- package/lib/tsc.js +183 -54
- package/lib/tsserver.js +201 -48
- package/lib/tsserverlibrary.js +201 -48
- package/lib/typescript.js +196 -45
- package/lib/typescriptServices.js +196 -45
- package/lib/typingsInstaller.js +193 -45
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -4
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -4
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211002";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -31359,7 +31359,6 @@ var ts;
|
|
|
31359
31359
|
case 88 /* DefaultKeyword */:
|
|
31360
31360
|
return nextTokenCanFollowDefaultKeyword();
|
|
31361
31361
|
case 124 /* StaticKeyword */:
|
|
31362
|
-
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
31363
31362
|
case 136 /* GetKeyword */:
|
|
31364
31363
|
case 148 /* SetKeyword */:
|
|
31365
31364
|
nextToken();
|
|
@@ -35602,7 +35601,7 @@ var ts;
|
|
|
35602
35601
|
}
|
|
35603
35602
|
return list && createNodeArray(list, pos);
|
|
35604
35603
|
}
|
|
35605
|
-
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35604
|
+
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
|
|
35606
35605
|
var pos = getNodePos();
|
|
35607
35606
|
var kind = token();
|
|
35608
35607
|
if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
@@ -35615,6 +35614,9 @@ var ts;
|
|
|
35615
35614
|
else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
|
|
35616
35615
|
return undefined;
|
|
35617
35616
|
}
|
|
35617
|
+
else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
|
|
35618
|
+
return undefined;
|
|
35619
|
+
}
|
|
35618
35620
|
else {
|
|
35619
35621
|
if (!parseAnyContextualModifier()) {
|
|
35620
35622
|
return undefined;
|
|
@@ -35631,8 +35633,10 @@ var ts;
|
|
|
35631
35633
|
*/
|
|
35632
35634
|
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35633
35635
|
var pos = getNodePos();
|
|
35634
|
-
var list, modifier;
|
|
35635
|
-
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
|
|
35636
|
+
var list, modifier, hasSeenStatic = false;
|
|
35637
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
35638
|
+
if (modifier.kind === 124 /* StaticKeyword */)
|
|
35639
|
+
hasSeenStatic = true;
|
|
35636
35640
|
list = ts.append(list, modifier);
|
|
35637
35641
|
}
|
|
35638
35642
|
return list && createNodeArray(list, pos);
|
|
@@ -40045,6 +40049,44 @@ var ts;
|
|
|
40045
40049
|
}
|
|
40046
40050
|
return result;
|
|
40047
40051
|
}
|
|
40052
|
+
/**
|
|
40053
|
+
* Generate a list of the compiler options whose value is not the default.
|
|
40054
|
+
* @param options compilerOptions to be evaluated.
|
|
40055
|
+
/** @internal */
|
|
40056
|
+
function getCompilerOptionsDiffValue(options, newLine) {
|
|
40057
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40058
|
+
return getOverwrittenDefaultOptions();
|
|
40059
|
+
function makePadding(paddingLength) {
|
|
40060
|
+
return Array(paddingLength + 1).join(" ");
|
|
40061
|
+
}
|
|
40062
|
+
function getOverwrittenDefaultOptions() {
|
|
40063
|
+
var result = [];
|
|
40064
|
+
var tab = makePadding(2);
|
|
40065
|
+
commandOptionsWithoutBuild.forEach(function (cmd) {
|
|
40066
|
+
if (!compilerOptionsMap.has(cmd.name)) {
|
|
40067
|
+
return;
|
|
40068
|
+
}
|
|
40069
|
+
var newValue = compilerOptionsMap.get(cmd.name);
|
|
40070
|
+
var defaultValue = getDefaultValueForOption(cmd);
|
|
40071
|
+
if (newValue !== defaultValue) {
|
|
40072
|
+
result.push("" + tab + cmd.name + ": " + newValue);
|
|
40073
|
+
}
|
|
40074
|
+
else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
|
|
40075
|
+
result.push("" + tab + cmd.name + ": " + defaultValue);
|
|
40076
|
+
}
|
|
40077
|
+
});
|
|
40078
|
+
return result.join(newLine) + newLine;
|
|
40079
|
+
}
|
|
40080
|
+
}
|
|
40081
|
+
ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
|
|
40082
|
+
/**
|
|
40083
|
+
* Get the compiler options to be written into the tsconfig.json.
|
|
40084
|
+
* @param options commandlineOptions to be included in the compileOptions.
|
|
40085
|
+
*/
|
|
40086
|
+
function getSerializedCompilerOption(options) {
|
|
40087
|
+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
40088
|
+
return serializeCompilerOptions(compilerOptions);
|
|
40089
|
+
}
|
|
40048
40090
|
/**
|
|
40049
40091
|
* Generate tsconfig configuration when running command line "--init"
|
|
40050
40092
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
@@ -40052,28 +40094,8 @@ var ts;
|
|
|
40052
40094
|
*/
|
|
40053
40095
|
/* @internal */
|
|
40054
40096
|
function generateTSConfig(options, fileNames, newLine) {
|
|
40055
|
-
var
|
|
40056
|
-
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
40097
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40057
40098
|
return writeConfigurations();
|
|
40058
|
-
function getDefaultValueForOption(option) {
|
|
40059
|
-
switch (option.type) {
|
|
40060
|
-
case "number":
|
|
40061
|
-
return 1;
|
|
40062
|
-
case "boolean":
|
|
40063
|
-
return true;
|
|
40064
|
-
case "string":
|
|
40065
|
-
return option.isFilePath ? "./" : "";
|
|
40066
|
-
case "list":
|
|
40067
|
-
return [];
|
|
40068
|
-
case "object":
|
|
40069
|
-
return {};
|
|
40070
|
-
default:
|
|
40071
|
-
var iterResult = option.type.keys().next();
|
|
40072
|
-
if (!iterResult.done)
|
|
40073
|
-
return iterResult.value;
|
|
40074
|
-
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
40075
|
-
}
|
|
40076
|
-
}
|
|
40077
40099
|
function makePadding(paddingLength) {
|
|
40078
40100
|
return Array(paddingLength + 1).join(" ");
|
|
40079
40101
|
}
|
|
@@ -41060,6 +41082,25 @@ var ts;
|
|
|
41060
41082
|
}); // TODO: GH#18217
|
|
41061
41083
|
}
|
|
41062
41084
|
}
|
|
41085
|
+
function getDefaultValueForOption(option) {
|
|
41086
|
+
switch (option.type) {
|
|
41087
|
+
case "number":
|
|
41088
|
+
return 1;
|
|
41089
|
+
case "boolean":
|
|
41090
|
+
return true;
|
|
41091
|
+
case "string":
|
|
41092
|
+
return option.isFilePath ? "./" : "";
|
|
41093
|
+
case "list":
|
|
41094
|
+
return [];
|
|
41095
|
+
case "object":
|
|
41096
|
+
return {};
|
|
41097
|
+
default:
|
|
41098
|
+
var iterResult = option.type.keys().next();
|
|
41099
|
+
if (!iterResult.done)
|
|
41100
|
+
return iterResult.value;
|
|
41101
|
+
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
41102
|
+
}
|
|
41103
|
+
}
|
|
41063
41104
|
})(ts || (ts = {}));
|
|
41064
41105
|
var ts;
|
|
41065
41106
|
(function (ts) {
|
|
@@ -42436,9 +42477,11 @@ var ts;
|
|
|
42436
42477
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42437
42478
|
}
|
|
42438
42479
|
ts.parsePackageName = parsePackageName;
|
|
42480
|
+
/* @internal */
|
|
42439
42481
|
function allKeysStartWithDot(obj) {
|
|
42440
42482
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42441
42483
|
}
|
|
42484
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42442
42485
|
function noKeyStartsWithDot(obj) {
|
|
42443
42486
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42444
42487
|
}
|
|
@@ -42645,17 +42688,19 @@ var ts;
|
|
|
42645
42688
|
}
|
|
42646
42689
|
return toSearchResult(/*value*/ undefined);
|
|
42647
42690
|
}
|
|
42648
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42649
|
-
if (conditions.indexOf("types") === -1)
|
|
42650
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42651
|
-
if (!ts.startsWith(key, "types@"))
|
|
42652
|
-
return false;
|
|
42653
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42654
|
-
if (!range)
|
|
42655
|
-
return false;
|
|
42656
|
-
return range.test(ts.version);
|
|
42657
|
-
}
|
|
42658
42691
|
}
|
|
42692
|
+
/* @internal */
|
|
42693
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42694
|
+
if (conditions.indexOf("types") === -1)
|
|
42695
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42696
|
+
if (!ts.startsWith(key, "types@"))
|
|
42697
|
+
return false;
|
|
42698
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42699
|
+
if (!range)
|
|
42700
|
+
return false;
|
|
42701
|
+
return range.test(ts.version);
|
|
42702
|
+
}
|
|
42703
|
+
ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
|
|
42659
42704
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42660
42705
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42661
42706
|
}
|
|
@@ -48709,7 +48754,21 @@ var ts;
|
|
|
48709
48754
|
function isSyntacticDefault(node) {
|
|
48710
48755
|
return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
|
|
48711
48756
|
}
|
|
48712
|
-
function
|
|
48757
|
+
function getUsageModeForExpression(usage) {
|
|
48758
|
+
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
|
|
48759
|
+
}
|
|
48760
|
+
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48761
|
+
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48762
|
+
}
|
|
48763
|
+
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48764
|
+
var usageMode = file && getUsageModeForExpression(usage);
|
|
48765
|
+
if (file && usageMode !== undefined) {
|
|
48766
|
+
var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
48767
|
+
if (usageMode === ts.ModuleKind.ESNext || result) {
|
|
48768
|
+
return result;
|
|
48769
|
+
}
|
|
48770
|
+
// fallthrough on cjs usages so we imply defaults for interop'd imports, too
|
|
48771
|
+
}
|
|
48713
48772
|
if (!allowSyntheticDefaultImports) {
|
|
48714
48773
|
return false;
|
|
48715
48774
|
}
|
|
@@ -48751,7 +48810,7 @@ var ts;
|
|
|
48751
48810
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48752
48811
|
}
|
|
48753
48812
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48754
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
|
|
48813
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48755
48814
|
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48756
48815
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48757
48816
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
@@ -48891,7 +48950,7 @@ var ts;
|
|
|
48891
48950
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
48892
48951
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
48893
48952
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48894
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
|
48953
|
+
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
48895
48954
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48896
48955
|
}
|
|
48897
48956
|
}
|
|
@@ -49582,7 +49641,7 @@ var ts;
|
|
|
49582
49641
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49583
49642
|
}
|
|
49584
49643
|
if (sigs && sigs.length) {
|
|
49585
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
|
|
49644
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
|
|
49586
49645
|
// Create a new symbol which has the module's type less the call and construct signatures
|
|
49587
49646
|
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49588
49647
|
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
@@ -74759,18 +74818,18 @@ var ts;
|
|
|
74759
74818
|
if (moduleSymbol) {
|
|
74760
74819
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74761
74820
|
if (esModuleSymbol) {
|
|
74762
|
-
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
|
|
74821
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74763
74822
|
}
|
|
74764
74823
|
}
|
|
74765
74824
|
return createPromiseReturnType(node, anyType);
|
|
74766
74825
|
}
|
|
74767
|
-
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74826
|
+
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74768
74827
|
var _a;
|
|
74769
74828
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74770
74829
|
var synthType = type;
|
|
74771
74830
|
if (!synthType.syntheticType) {
|
|
74772
74831
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74773
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
|
|
74832
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74774
74833
|
if (hasSyntheticDefault) {
|
|
74775
74834
|
var memberTable = ts.createSymbolTable();
|
|
74776
74835
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
@@ -87381,7 +87440,7 @@ var ts;
|
|
|
87381
87440
|
}
|
|
87382
87441
|
ts.createSourceMapGenerator = createSourceMapGenerator;
|
|
87383
87442
|
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
|
87384
|
-
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)
|
|
87443
|
+
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
|
87385
87444
|
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
|
87386
87445
|
function getLineInfo(text, lineStarts) {
|
|
87387
87446
|
return {
|
|
@@ -118884,6 +118943,78 @@ var ts;
|
|
|
118884
118943
|
}
|
|
118885
118944
|
}
|
|
118886
118945
|
}
|
|
118946
|
+
var MatchingMode;
|
|
118947
|
+
(function (MatchingMode) {
|
|
118948
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
118949
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
118950
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
118951
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
118952
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
118953
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
118954
|
+
if (typeof exports === "string") {
|
|
118955
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
118956
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
118957
|
+
switch (mode) {
|
|
118958
|
+
case 0 /* Exact */:
|
|
118959
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
118960
|
+
return { moduleFileToTry: packageName };
|
|
118961
|
+
}
|
|
118962
|
+
break;
|
|
118963
|
+
case 1 /* Directory */:
|
|
118964
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
118965
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
118966
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
118967
|
+
}
|
|
118968
|
+
break;
|
|
118969
|
+
case 2 /* Pattern */:
|
|
118970
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
118971
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
118972
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
118973
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
118974
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
118975
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118976
|
+
}
|
|
118977
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
118978
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
118979
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118980
|
+
}
|
|
118981
|
+
break;
|
|
118982
|
+
}
|
|
118983
|
+
}
|
|
118984
|
+
else if (Array.isArray(exports)) {
|
|
118985
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
118986
|
+
}
|
|
118987
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
118988
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
118989
|
+
// sub-mappings
|
|
118990
|
+
// 3 cases:
|
|
118991
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
118992
|
+
// * pattern mappings (contains a *)
|
|
118993
|
+
// * exact mappings (no *, does not end with /)
|
|
118994
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
118995
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
118996
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
118997
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
118998
|
+
: 0 /* Exact */;
|
|
118999
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
119000
|
+
});
|
|
119001
|
+
}
|
|
119002
|
+
else {
|
|
119003
|
+
// conditional mapping
|
|
119004
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
119005
|
+
var key = _a[_i];
|
|
119006
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
119007
|
+
var subTarget = exports[key];
|
|
119008
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
119009
|
+
if (result) {
|
|
119010
|
+
return result;
|
|
119011
|
+
}
|
|
119012
|
+
}
|
|
119013
|
+
}
|
|
119014
|
+
}
|
|
119015
|
+
}
|
|
119016
|
+
return undefined;
|
|
119017
|
+
}
|
|
118887
119018
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
118888
119019
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
118889
119020
|
if (normalizedTargetPath === undefined) {
|
|
@@ -118913,7 +119044,15 @@ var ts;
|
|
|
118913
119044
|
var moduleFileNameForExtensionless = void 0;
|
|
118914
119045
|
while (true) {
|
|
118915
119046
|
// If the module could be imported by a directory name, use that directory's name
|
|
118916
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119047
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119048
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119049
|
+
if (blockedByExports) {
|
|
119050
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119051
|
+
}
|
|
119052
|
+
if (verbatimFromExports) {
|
|
119053
|
+
return moduleFileToTry;
|
|
119054
|
+
}
|
|
119055
|
+
}
|
|
118917
119056
|
if (packageRootPath) {
|
|
118918
119057
|
moduleSpecifier = packageRootPath;
|
|
118919
119058
|
isPackageRootPath = true;
|
|
@@ -118950,6 +119089,15 @@ var ts;
|
|
|
118950
119089
|
var moduleFileToTry = path;
|
|
118951
119090
|
if (host.fileExists(packageJsonPath)) {
|
|
118952
119091
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119092
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119093
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119094
|
+
if (fromExports) {
|
|
119095
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119096
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119097
|
+
}
|
|
119098
|
+
if (packageJsonContent.exports) {
|
|
119099
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119100
|
+
}
|
|
118953
119101
|
var versionPaths = packageJsonContent.typesVersions
|
|
118954
119102
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
118955
119103
|
: undefined;
|
|
@@ -138082,6 +138230,7 @@ var ts;
|
|
|
138082
138230
|
return false;
|
|
138083
138231
|
}
|
|
138084
138232
|
}
|
|
138233
|
+
Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
|
|
138085
138234
|
})(Rename = ts.Rename || (ts.Rename = {}));
|
|
138086
138235
|
})(ts || (ts = {}));
|
|
138087
138236
|
/* @internal */
|
|
@@ -159378,6 +159527,8 @@ var ts;
|
|
|
159378
159527
|
synchronizeHostData();
|
|
159379
159528
|
var sourceFile = getValidSourceFile(fileName);
|
|
159380
159529
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
159530
|
+
if (!ts.Rename.nodeIsEligibleForRename(node))
|
|
159531
|
+
return undefined;
|
|
159381
159532
|
if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
|
|
159382
159533
|
var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
|
|
159383
159534
|
return [openingElement, closingElement].map(function (node) {
|
|
@@ -170476,11 +170627,13 @@ var ts;
|
|
|
170476
170627
|
var file = server.toNormalizedPath(args.file);
|
|
170477
170628
|
var position = this.getPositionInFile(args, file);
|
|
170478
170629
|
var projects = this.getProjects(args);
|
|
170479
|
-
var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
|
|
170480
|
-
if (!simplifiedResult)
|
|
170481
|
-
return locations;
|
|
170482
170630
|
var defaultProject = this.getDefaultProject(args);
|
|
170483
170631
|
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
170632
|
+
if (!renameInfo.canRename)
|
|
170633
|
+
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
170634
|
+
var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
|
|
170635
|
+
if (!simplifiedResult)
|
|
170636
|
+
return locations;
|
|
170484
170637
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|
|
170485
170638
|
};
|
|
170486
170639
|
Session.prototype.mapRenameInfo = function (info, scriptInfo) {
|