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/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211002";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -31553,7 +31553,6 @@ var ts;
|
|
|
31553
31553
|
case 88 /* DefaultKeyword */:
|
|
31554
31554
|
return nextTokenCanFollowDefaultKeyword();
|
|
31555
31555
|
case 124 /* StaticKeyword */:
|
|
31556
|
-
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
31557
31556
|
case 136 /* GetKeyword */:
|
|
31558
31557
|
case 148 /* SetKeyword */:
|
|
31559
31558
|
nextToken();
|
|
@@ -35796,7 +35795,7 @@ var ts;
|
|
|
35796
35795
|
}
|
|
35797
35796
|
return list && createNodeArray(list, pos);
|
|
35798
35797
|
}
|
|
35799
|
-
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35798
|
+
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
|
|
35800
35799
|
var pos = getNodePos();
|
|
35801
35800
|
var kind = token();
|
|
35802
35801
|
if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
@@ -35809,6 +35808,9 @@ var ts;
|
|
|
35809
35808
|
else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
|
|
35810
35809
|
return undefined;
|
|
35811
35810
|
}
|
|
35811
|
+
else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
|
|
35812
|
+
return undefined;
|
|
35813
|
+
}
|
|
35812
35814
|
else {
|
|
35813
35815
|
if (!parseAnyContextualModifier()) {
|
|
35814
35816
|
return undefined;
|
|
@@ -35825,8 +35827,10 @@ var ts;
|
|
|
35825
35827
|
*/
|
|
35826
35828
|
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35827
35829
|
var pos = getNodePos();
|
|
35828
|
-
var list, modifier;
|
|
35829
|
-
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
|
|
35830
|
+
var list, modifier, hasSeenStatic = false;
|
|
35831
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
35832
|
+
if (modifier.kind === 124 /* StaticKeyword */)
|
|
35833
|
+
hasSeenStatic = true;
|
|
35830
35834
|
list = ts.append(list, modifier);
|
|
35831
35835
|
}
|
|
35832
35836
|
return list && createNodeArray(list, pos);
|
|
@@ -40239,6 +40243,44 @@ var ts;
|
|
|
40239
40243
|
}
|
|
40240
40244
|
return result;
|
|
40241
40245
|
}
|
|
40246
|
+
/**
|
|
40247
|
+
* Generate a list of the compiler options whose value is not the default.
|
|
40248
|
+
* @param options compilerOptions to be evaluated.
|
|
40249
|
+
/** @internal */
|
|
40250
|
+
function getCompilerOptionsDiffValue(options, newLine) {
|
|
40251
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40252
|
+
return getOverwrittenDefaultOptions();
|
|
40253
|
+
function makePadding(paddingLength) {
|
|
40254
|
+
return Array(paddingLength + 1).join(" ");
|
|
40255
|
+
}
|
|
40256
|
+
function getOverwrittenDefaultOptions() {
|
|
40257
|
+
var result = [];
|
|
40258
|
+
var tab = makePadding(2);
|
|
40259
|
+
commandOptionsWithoutBuild.forEach(function (cmd) {
|
|
40260
|
+
if (!compilerOptionsMap.has(cmd.name)) {
|
|
40261
|
+
return;
|
|
40262
|
+
}
|
|
40263
|
+
var newValue = compilerOptionsMap.get(cmd.name);
|
|
40264
|
+
var defaultValue = getDefaultValueForOption(cmd);
|
|
40265
|
+
if (newValue !== defaultValue) {
|
|
40266
|
+
result.push("" + tab + cmd.name + ": " + newValue);
|
|
40267
|
+
}
|
|
40268
|
+
else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
|
|
40269
|
+
result.push("" + tab + cmd.name + ": " + defaultValue);
|
|
40270
|
+
}
|
|
40271
|
+
});
|
|
40272
|
+
return result.join(newLine) + newLine;
|
|
40273
|
+
}
|
|
40274
|
+
}
|
|
40275
|
+
ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
|
|
40276
|
+
/**
|
|
40277
|
+
* Get the compiler options to be written into the tsconfig.json.
|
|
40278
|
+
* @param options commandlineOptions to be included in the compileOptions.
|
|
40279
|
+
*/
|
|
40280
|
+
function getSerializedCompilerOption(options) {
|
|
40281
|
+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
40282
|
+
return serializeCompilerOptions(compilerOptions);
|
|
40283
|
+
}
|
|
40242
40284
|
/**
|
|
40243
40285
|
* Generate tsconfig configuration when running command line "--init"
|
|
40244
40286
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
@@ -40246,28 +40288,8 @@ var ts;
|
|
|
40246
40288
|
*/
|
|
40247
40289
|
/* @internal */
|
|
40248
40290
|
function generateTSConfig(options, fileNames, newLine) {
|
|
40249
|
-
var
|
|
40250
|
-
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
40291
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40251
40292
|
return writeConfigurations();
|
|
40252
|
-
function getDefaultValueForOption(option) {
|
|
40253
|
-
switch (option.type) {
|
|
40254
|
-
case "number":
|
|
40255
|
-
return 1;
|
|
40256
|
-
case "boolean":
|
|
40257
|
-
return true;
|
|
40258
|
-
case "string":
|
|
40259
|
-
return option.isFilePath ? "./" : "";
|
|
40260
|
-
case "list":
|
|
40261
|
-
return [];
|
|
40262
|
-
case "object":
|
|
40263
|
-
return {};
|
|
40264
|
-
default:
|
|
40265
|
-
var iterResult = option.type.keys().next();
|
|
40266
|
-
if (!iterResult.done)
|
|
40267
|
-
return iterResult.value;
|
|
40268
|
-
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
40269
|
-
}
|
|
40270
|
-
}
|
|
40271
40293
|
function makePadding(paddingLength) {
|
|
40272
40294
|
return Array(paddingLength + 1).join(" ");
|
|
40273
40295
|
}
|
|
@@ -41254,6 +41276,25 @@ var ts;
|
|
|
41254
41276
|
}); // TODO: GH#18217
|
|
41255
41277
|
}
|
|
41256
41278
|
}
|
|
41279
|
+
function getDefaultValueForOption(option) {
|
|
41280
|
+
switch (option.type) {
|
|
41281
|
+
case "number":
|
|
41282
|
+
return 1;
|
|
41283
|
+
case "boolean":
|
|
41284
|
+
return true;
|
|
41285
|
+
case "string":
|
|
41286
|
+
return option.isFilePath ? "./" : "";
|
|
41287
|
+
case "list":
|
|
41288
|
+
return [];
|
|
41289
|
+
case "object":
|
|
41290
|
+
return {};
|
|
41291
|
+
default:
|
|
41292
|
+
var iterResult = option.type.keys().next();
|
|
41293
|
+
if (!iterResult.done)
|
|
41294
|
+
return iterResult.value;
|
|
41295
|
+
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
41296
|
+
}
|
|
41297
|
+
}
|
|
41257
41298
|
})(ts || (ts = {}));
|
|
41258
41299
|
var ts;
|
|
41259
41300
|
(function (ts) {
|
|
@@ -42630,9 +42671,11 @@ var ts;
|
|
|
42630
42671
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42631
42672
|
}
|
|
42632
42673
|
ts.parsePackageName = parsePackageName;
|
|
42674
|
+
/* @internal */
|
|
42633
42675
|
function allKeysStartWithDot(obj) {
|
|
42634
42676
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42635
42677
|
}
|
|
42678
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42636
42679
|
function noKeyStartsWithDot(obj) {
|
|
42637
42680
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42638
42681
|
}
|
|
@@ -42839,17 +42882,19 @@ var ts;
|
|
|
42839
42882
|
}
|
|
42840
42883
|
return toSearchResult(/*value*/ undefined);
|
|
42841
42884
|
}
|
|
42842
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42843
|
-
if (conditions.indexOf("types") === -1)
|
|
42844
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42845
|
-
if (!ts.startsWith(key, "types@"))
|
|
42846
|
-
return false;
|
|
42847
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42848
|
-
if (!range)
|
|
42849
|
-
return false;
|
|
42850
|
-
return range.test(ts.version);
|
|
42851
|
-
}
|
|
42852
42885
|
}
|
|
42886
|
+
/* @internal */
|
|
42887
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42888
|
+
if (conditions.indexOf("types") === -1)
|
|
42889
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42890
|
+
if (!ts.startsWith(key, "types@"))
|
|
42891
|
+
return false;
|
|
42892
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42893
|
+
if (!range)
|
|
42894
|
+
return false;
|
|
42895
|
+
return range.test(ts.version);
|
|
42896
|
+
}
|
|
42897
|
+
ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
|
|
42853
42898
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42854
42899
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42855
42900
|
}
|
|
@@ -48903,7 +48948,21 @@ var ts;
|
|
|
48903
48948
|
function isSyntacticDefault(node) {
|
|
48904
48949
|
return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
|
|
48905
48950
|
}
|
|
48906
|
-
function
|
|
48951
|
+
function getUsageModeForExpression(usage) {
|
|
48952
|
+
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
|
|
48953
|
+
}
|
|
48954
|
+
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48955
|
+
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48956
|
+
}
|
|
48957
|
+
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48958
|
+
var usageMode = file && getUsageModeForExpression(usage);
|
|
48959
|
+
if (file && usageMode !== undefined) {
|
|
48960
|
+
var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
48961
|
+
if (usageMode === ts.ModuleKind.ESNext || result) {
|
|
48962
|
+
return result;
|
|
48963
|
+
}
|
|
48964
|
+
// fallthrough on cjs usages so we imply defaults for interop'd imports, too
|
|
48965
|
+
}
|
|
48907
48966
|
if (!allowSyntheticDefaultImports) {
|
|
48908
48967
|
return false;
|
|
48909
48968
|
}
|
|
@@ -48945,7 +49004,7 @@ var ts;
|
|
|
48945
49004
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48946
49005
|
}
|
|
48947
49006
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48948
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
|
|
49007
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48949
49008
|
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48950
49009
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48951
49010
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
@@ -49085,7 +49144,7 @@ var ts;
|
|
|
49085
49144
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49086
49145
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49087
49146
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49088
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
|
49147
|
+
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49089
49148
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49090
49149
|
}
|
|
49091
49150
|
}
|
|
@@ -49776,7 +49835,7 @@ var ts;
|
|
|
49776
49835
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49777
49836
|
}
|
|
49778
49837
|
if (sigs && sigs.length) {
|
|
49779
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
|
|
49838
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
|
|
49780
49839
|
// Create a new symbol which has the module's type less the call and construct signatures
|
|
49781
49840
|
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49782
49841
|
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
@@ -74953,18 +75012,18 @@ var ts;
|
|
|
74953
75012
|
if (moduleSymbol) {
|
|
74954
75013
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74955
75014
|
if (esModuleSymbol) {
|
|
74956
|
-
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
|
|
75015
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74957
75016
|
}
|
|
74958
75017
|
}
|
|
74959
75018
|
return createPromiseReturnType(node, anyType);
|
|
74960
75019
|
}
|
|
74961
|
-
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
75020
|
+
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74962
75021
|
var _a;
|
|
74963
75022
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74964
75023
|
var synthType = type;
|
|
74965
75024
|
if (!synthType.syntheticType) {
|
|
74966
75025
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74967
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
|
|
75026
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74968
75027
|
if (hasSyntheticDefault) {
|
|
74969
75028
|
var memberTable = ts.createSymbolTable();
|
|
74970
75029
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
@@ -87575,7 +87634,7 @@ var ts;
|
|
|
87575
87634
|
}
|
|
87576
87635
|
ts.createSourceMapGenerator = createSourceMapGenerator;
|
|
87577
87636
|
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
|
87578
|
-
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)
|
|
87637
|
+
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
|
87579
87638
|
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
|
87580
87639
|
function getLineInfo(text, lineStarts) {
|
|
87581
87640
|
return {
|
|
@@ -119078,6 +119137,78 @@ var ts;
|
|
|
119078
119137
|
}
|
|
119079
119138
|
}
|
|
119080
119139
|
}
|
|
119140
|
+
var MatchingMode;
|
|
119141
|
+
(function (MatchingMode) {
|
|
119142
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
119143
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
119144
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
119145
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
119146
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
119147
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
119148
|
+
if (typeof exports === "string") {
|
|
119149
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
119150
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
119151
|
+
switch (mode) {
|
|
119152
|
+
case 0 /* Exact */:
|
|
119153
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
119154
|
+
return { moduleFileToTry: packageName };
|
|
119155
|
+
}
|
|
119156
|
+
break;
|
|
119157
|
+
case 1 /* Directory */:
|
|
119158
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
119159
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
119160
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
119161
|
+
}
|
|
119162
|
+
break;
|
|
119163
|
+
case 2 /* Pattern */:
|
|
119164
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
119165
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
119166
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
119167
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
119168
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
119169
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119170
|
+
}
|
|
119171
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
119172
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
119173
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119174
|
+
}
|
|
119175
|
+
break;
|
|
119176
|
+
}
|
|
119177
|
+
}
|
|
119178
|
+
else if (Array.isArray(exports)) {
|
|
119179
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
119180
|
+
}
|
|
119181
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
119182
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
119183
|
+
// sub-mappings
|
|
119184
|
+
// 3 cases:
|
|
119185
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
119186
|
+
// * pattern mappings (contains a *)
|
|
119187
|
+
// * exact mappings (no *, does not end with /)
|
|
119188
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
119189
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
119190
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
119191
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
119192
|
+
: 0 /* Exact */;
|
|
119193
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
119194
|
+
});
|
|
119195
|
+
}
|
|
119196
|
+
else {
|
|
119197
|
+
// conditional mapping
|
|
119198
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
119199
|
+
var key = _a[_i];
|
|
119200
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
119201
|
+
var subTarget = exports[key];
|
|
119202
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
119203
|
+
if (result) {
|
|
119204
|
+
return result;
|
|
119205
|
+
}
|
|
119206
|
+
}
|
|
119207
|
+
}
|
|
119208
|
+
}
|
|
119209
|
+
}
|
|
119210
|
+
return undefined;
|
|
119211
|
+
}
|
|
119081
119212
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
119082
119213
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
119083
119214
|
if (normalizedTargetPath === undefined) {
|
|
@@ -119107,7 +119238,15 @@ var ts;
|
|
|
119107
119238
|
var moduleFileNameForExtensionless = void 0;
|
|
119108
119239
|
while (true) {
|
|
119109
119240
|
// If the module could be imported by a directory name, use that directory's name
|
|
119110
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119241
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119242
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119243
|
+
if (blockedByExports) {
|
|
119244
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119245
|
+
}
|
|
119246
|
+
if (verbatimFromExports) {
|
|
119247
|
+
return moduleFileToTry;
|
|
119248
|
+
}
|
|
119249
|
+
}
|
|
119111
119250
|
if (packageRootPath) {
|
|
119112
119251
|
moduleSpecifier = packageRootPath;
|
|
119113
119252
|
isPackageRootPath = true;
|
|
@@ -119144,6 +119283,15 @@ var ts;
|
|
|
119144
119283
|
var moduleFileToTry = path;
|
|
119145
119284
|
if (host.fileExists(packageJsonPath)) {
|
|
119146
119285
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119286
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119287
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119288
|
+
if (fromExports) {
|
|
119289
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119290
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119291
|
+
}
|
|
119292
|
+
if (packageJsonContent.exports) {
|
|
119293
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119294
|
+
}
|
|
119147
119295
|
var versionPaths = packageJsonContent.typesVersions
|
|
119148
119296
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
119149
119297
|
: undefined;
|
|
@@ -138664,6 +138812,7 @@ var ts;
|
|
|
138664
138812
|
return false;
|
|
138665
138813
|
}
|
|
138666
138814
|
}
|
|
138815
|
+
Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
|
|
138667
138816
|
})(Rename = ts.Rename || (ts.Rename = {}));
|
|
138668
138817
|
})(ts || (ts = {}));
|
|
138669
138818
|
/* @internal */
|
|
@@ -159960,6 +160109,8 @@ var ts;
|
|
|
159960
160109
|
synchronizeHostData();
|
|
159961
160110
|
var sourceFile = getValidSourceFile(fileName);
|
|
159962
160111
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
160112
|
+
if (!ts.Rename.nodeIsEligibleForRename(node))
|
|
160113
|
+
return undefined;
|
|
159963
160114
|
if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
|
|
159964
160115
|
var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
|
|
159965
160116
|
return [openingElement, closingElement].map(function (node) {
|
|
@@ -170670,11 +170821,13 @@ var ts;
|
|
|
170670
170821
|
var file = server.toNormalizedPath(args.file);
|
|
170671
170822
|
var position = this.getPositionInFile(args, file);
|
|
170672
170823
|
var projects = this.getProjects(args);
|
|
170673
|
-
var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
|
|
170674
|
-
if (!simplifiedResult)
|
|
170675
|
-
return locations;
|
|
170676
170824
|
var defaultProject = this.getDefaultProject(args);
|
|
170677
170825
|
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
170826
|
+
if (!renameInfo.canRename)
|
|
170827
|
+
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
170828
|
+
var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
|
|
170829
|
+
if (!simplifiedResult)
|
|
170830
|
+
return locations;
|
|
170678
170831
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|
|
170679
170832
|
};
|
|
170680
170833
|
Session.prototype.mapRenameInfo = function (info, scriptInfo) {
|