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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211002";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -31348,7 +31348,6 @@ var ts;
|
|
|
31348
31348
|
case 88 /* DefaultKeyword */:
|
|
31349
31349
|
return nextTokenCanFollowDefaultKeyword();
|
|
31350
31350
|
case 124 /* StaticKeyword */:
|
|
31351
|
-
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
31352
31351
|
case 136 /* GetKeyword */:
|
|
31353
31352
|
case 148 /* SetKeyword */:
|
|
31354
31353
|
nextToken();
|
|
@@ -35591,7 +35590,7 @@ var ts;
|
|
|
35591
35590
|
}
|
|
35592
35591
|
return list && createNodeArray(list, pos);
|
|
35593
35592
|
}
|
|
35594
|
-
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35593
|
+
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
|
|
35595
35594
|
var pos = getNodePos();
|
|
35596
35595
|
var kind = token();
|
|
35597
35596
|
if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
@@ -35604,6 +35603,9 @@ var ts;
|
|
|
35604
35603
|
else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
|
|
35605
35604
|
return undefined;
|
|
35606
35605
|
}
|
|
35606
|
+
else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
|
|
35607
|
+
return undefined;
|
|
35608
|
+
}
|
|
35607
35609
|
else {
|
|
35608
35610
|
if (!parseAnyContextualModifier()) {
|
|
35609
35611
|
return undefined;
|
|
@@ -35620,8 +35622,10 @@ var ts;
|
|
|
35620
35622
|
*/
|
|
35621
35623
|
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35622
35624
|
var pos = getNodePos();
|
|
35623
|
-
var list, modifier;
|
|
35624
|
-
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
|
|
35625
|
+
var list, modifier, hasSeenStatic = false;
|
|
35626
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
35627
|
+
if (modifier.kind === 124 /* StaticKeyword */)
|
|
35628
|
+
hasSeenStatic = true;
|
|
35625
35629
|
list = ts.append(list, modifier);
|
|
35626
35630
|
}
|
|
35627
35631
|
return list && createNodeArray(list, pos);
|
|
@@ -40034,6 +40038,44 @@ var ts;
|
|
|
40034
40038
|
}
|
|
40035
40039
|
return result;
|
|
40036
40040
|
}
|
|
40041
|
+
/**
|
|
40042
|
+
* Generate a list of the compiler options whose value is not the default.
|
|
40043
|
+
* @param options compilerOptions to be evaluated.
|
|
40044
|
+
/** @internal */
|
|
40045
|
+
function getCompilerOptionsDiffValue(options, newLine) {
|
|
40046
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40047
|
+
return getOverwrittenDefaultOptions();
|
|
40048
|
+
function makePadding(paddingLength) {
|
|
40049
|
+
return Array(paddingLength + 1).join(" ");
|
|
40050
|
+
}
|
|
40051
|
+
function getOverwrittenDefaultOptions() {
|
|
40052
|
+
var result = [];
|
|
40053
|
+
var tab = makePadding(2);
|
|
40054
|
+
commandOptionsWithoutBuild.forEach(function (cmd) {
|
|
40055
|
+
if (!compilerOptionsMap.has(cmd.name)) {
|
|
40056
|
+
return;
|
|
40057
|
+
}
|
|
40058
|
+
var newValue = compilerOptionsMap.get(cmd.name);
|
|
40059
|
+
var defaultValue = getDefaultValueForOption(cmd);
|
|
40060
|
+
if (newValue !== defaultValue) {
|
|
40061
|
+
result.push("" + tab + cmd.name + ": " + newValue);
|
|
40062
|
+
}
|
|
40063
|
+
else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
|
|
40064
|
+
result.push("" + tab + cmd.name + ": " + defaultValue);
|
|
40065
|
+
}
|
|
40066
|
+
});
|
|
40067
|
+
return result.join(newLine) + newLine;
|
|
40068
|
+
}
|
|
40069
|
+
}
|
|
40070
|
+
ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
|
|
40071
|
+
/**
|
|
40072
|
+
* Get the compiler options to be written into the tsconfig.json.
|
|
40073
|
+
* @param options commandlineOptions to be included in the compileOptions.
|
|
40074
|
+
*/
|
|
40075
|
+
function getSerializedCompilerOption(options) {
|
|
40076
|
+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
40077
|
+
return serializeCompilerOptions(compilerOptions);
|
|
40078
|
+
}
|
|
40037
40079
|
/**
|
|
40038
40080
|
* Generate tsconfig configuration when running command line "--init"
|
|
40039
40081
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
@@ -40041,28 +40083,8 @@ var ts;
|
|
|
40041
40083
|
*/
|
|
40042
40084
|
/* @internal */
|
|
40043
40085
|
function generateTSConfig(options, fileNames, newLine) {
|
|
40044
|
-
var
|
|
40045
|
-
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
40086
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40046
40087
|
return writeConfigurations();
|
|
40047
|
-
function getDefaultValueForOption(option) {
|
|
40048
|
-
switch (option.type) {
|
|
40049
|
-
case "number":
|
|
40050
|
-
return 1;
|
|
40051
|
-
case "boolean":
|
|
40052
|
-
return true;
|
|
40053
|
-
case "string":
|
|
40054
|
-
return option.isFilePath ? "./" : "";
|
|
40055
|
-
case "list":
|
|
40056
|
-
return [];
|
|
40057
|
-
case "object":
|
|
40058
|
-
return {};
|
|
40059
|
-
default:
|
|
40060
|
-
var iterResult = option.type.keys().next();
|
|
40061
|
-
if (!iterResult.done)
|
|
40062
|
-
return iterResult.value;
|
|
40063
|
-
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
40064
|
-
}
|
|
40065
|
-
}
|
|
40066
40088
|
function makePadding(paddingLength) {
|
|
40067
40089
|
return Array(paddingLength + 1).join(" ");
|
|
40068
40090
|
}
|
|
@@ -41049,6 +41071,25 @@ var ts;
|
|
|
41049
41071
|
}); // TODO: GH#18217
|
|
41050
41072
|
}
|
|
41051
41073
|
}
|
|
41074
|
+
function getDefaultValueForOption(option) {
|
|
41075
|
+
switch (option.type) {
|
|
41076
|
+
case "number":
|
|
41077
|
+
return 1;
|
|
41078
|
+
case "boolean":
|
|
41079
|
+
return true;
|
|
41080
|
+
case "string":
|
|
41081
|
+
return option.isFilePath ? "./" : "";
|
|
41082
|
+
case "list":
|
|
41083
|
+
return [];
|
|
41084
|
+
case "object":
|
|
41085
|
+
return {};
|
|
41086
|
+
default:
|
|
41087
|
+
var iterResult = option.type.keys().next();
|
|
41088
|
+
if (!iterResult.done)
|
|
41089
|
+
return iterResult.value;
|
|
41090
|
+
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
41091
|
+
}
|
|
41092
|
+
}
|
|
41052
41093
|
})(ts || (ts = {}));
|
|
41053
41094
|
var ts;
|
|
41054
41095
|
(function (ts) {
|
|
@@ -42425,9 +42466,11 @@ var ts;
|
|
|
42425
42466
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42426
42467
|
}
|
|
42427
42468
|
ts.parsePackageName = parsePackageName;
|
|
42469
|
+
/* @internal */
|
|
42428
42470
|
function allKeysStartWithDot(obj) {
|
|
42429
42471
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42430
42472
|
}
|
|
42473
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42431
42474
|
function noKeyStartsWithDot(obj) {
|
|
42432
42475
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42433
42476
|
}
|
|
@@ -42634,17 +42677,19 @@ var ts;
|
|
|
42634
42677
|
}
|
|
42635
42678
|
return toSearchResult(/*value*/ undefined);
|
|
42636
42679
|
}
|
|
42637
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42638
|
-
if (conditions.indexOf("types") === -1)
|
|
42639
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42640
|
-
if (!ts.startsWith(key, "types@"))
|
|
42641
|
-
return false;
|
|
42642
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42643
|
-
if (!range)
|
|
42644
|
-
return false;
|
|
42645
|
-
return range.test(ts.version);
|
|
42646
|
-
}
|
|
42647
42680
|
}
|
|
42681
|
+
/* @internal */
|
|
42682
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42683
|
+
if (conditions.indexOf("types") === -1)
|
|
42684
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42685
|
+
if (!ts.startsWith(key, "types@"))
|
|
42686
|
+
return false;
|
|
42687
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42688
|
+
if (!range)
|
|
42689
|
+
return false;
|
|
42690
|
+
return range.test(ts.version);
|
|
42691
|
+
}
|
|
42692
|
+
ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
|
|
42648
42693
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42649
42694
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42650
42695
|
}
|
|
@@ -48698,7 +48743,21 @@ var ts;
|
|
|
48698
48743
|
function isSyntacticDefault(node) {
|
|
48699
48744
|
return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
|
|
48700
48745
|
}
|
|
48701
|
-
function
|
|
48746
|
+
function getUsageModeForExpression(usage) {
|
|
48747
|
+
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
|
|
48748
|
+
}
|
|
48749
|
+
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48750
|
+
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48751
|
+
}
|
|
48752
|
+
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48753
|
+
var usageMode = file && getUsageModeForExpression(usage);
|
|
48754
|
+
if (file && usageMode !== undefined) {
|
|
48755
|
+
var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
48756
|
+
if (usageMode === ts.ModuleKind.ESNext || result) {
|
|
48757
|
+
return result;
|
|
48758
|
+
}
|
|
48759
|
+
// fallthrough on cjs usages so we imply defaults for interop'd imports, too
|
|
48760
|
+
}
|
|
48702
48761
|
if (!allowSyntheticDefaultImports) {
|
|
48703
48762
|
return false;
|
|
48704
48763
|
}
|
|
@@ -48740,7 +48799,7 @@ var ts;
|
|
|
48740
48799
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48741
48800
|
}
|
|
48742
48801
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48743
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
|
|
48802
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48744
48803
|
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48745
48804
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48746
48805
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
@@ -48880,7 +48939,7 @@ var ts;
|
|
|
48880
48939
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
48881
48940
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
48882
48941
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48883
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
|
48942
|
+
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
48884
48943
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48885
48944
|
}
|
|
48886
48945
|
}
|
|
@@ -49571,7 +49630,7 @@ var ts;
|
|
|
49571
49630
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49572
49631
|
}
|
|
49573
49632
|
if (sigs && sigs.length) {
|
|
49574
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
|
|
49633
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
|
|
49575
49634
|
// Create a new symbol which has the module's type less the call and construct signatures
|
|
49576
49635
|
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49577
49636
|
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
@@ -74748,18 +74807,18 @@ var ts;
|
|
|
74748
74807
|
if (moduleSymbol) {
|
|
74749
74808
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74750
74809
|
if (esModuleSymbol) {
|
|
74751
|
-
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
|
|
74810
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74752
74811
|
}
|
|
74753
74812
|
}
|
|
74754
74813
|
return createPromiseReturnType(node, anyType);
|
|
74755
74814
|
}
|
|
74756
|
-
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74815
|
+
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74757
74816
|
var _a;
|
|
74758
74817
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74759
74818
|
var synthType = type;
|
|
74760
74819
|
if (!synthType.syntheticType) {
|
|
74761
74820
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74762
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
|
|
74821
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74763
74822
|
if (hasSyntheticDefault) {
|
|
74764
74823
|
var memberTable = ts.createSymbolTable();
|
|
74765
74824
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
@@ -87370,7 +87429,7 @@ var ts;
|
|
|
87370
87429
|
}
|
|
87371
87430
|
ts.createSourceMapGenerator = createSourceMapGenerator;
|
|
87372
87431
|
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
|
87373
|
-
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)
|
|
87432
|
+
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
|
87374
87433
|
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
|
87375
87434
|
function getLineInfo(text, lineStarts) {
|
|
87376
87435
|
return {
|
|
@@ -118873,6 +118932,78 @@ var ts;
|
|
|
118873
118932
|
}
|
|
118874
118933
|
}
|
|
118875
118934
|
}
|
|
118935
|
+
var MatchingMode;
|
|
118936
|
+
(function (MatchingMode) {
|
|
118937
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
118938
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
118939
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
118940
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
118941
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
118942
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
118943
|
+
if (typeof exports === "string") {
|
|
118944
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
118945
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
118946
|
+
switch (mode) {
|
|
118947
|
+
case 0 /* Exact */:
|
|
118948
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
118949
|
+
return { moduleFileToTry: packageName };
|
|
118950
|
+
}
|
|
118951
|
+
break;
|
|
118952
|
+
case 1 /* Directory */:
|
|
118953
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
118954
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
118955
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
118956
|
+
}
|
|
118957
|
+
break;
|
|
118958
|
+
case 2 /* Pattern */:
|
|
118959
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
118960
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
118961
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
118962
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
118963
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
118964
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118965
|
+
}
|
|
118966
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
118967
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
118968
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118969
|
+
}
|
|
118970
|
+
break;
|
|
118971
|
+
}
|
|
118972
|
+
}
|
|
118973
|
+
else if (Array.isArray(exports)) {
|
|
118974
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
118975
|
+
}
|
|
118976
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
118977
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
118978
|
+
// sub-mappings
|
|
118979
|
+
// 3 cases:
|
|
118980
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
118981
|
+
// * pattern mappings (contains a *)
|
|
118982
|
+
// * exact mappings (no *, does not end with /)
|
|
118983
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
118984
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
118985
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
118986
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
118987
|
+
: 0 /* Exact */;
|
|
118988
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
118989
|
+
});
|
|
118990
|
+
}
|
|
118991
|
+
else {
|
|
118992
|
+
// conditional mapping
|
|
118993
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
118994
|
+
var key = _a[_i];
|
|
118995
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
118996
|
+
var subTarget = exports[key];
|
|
118997
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
118998
|
+
if (result) {
|
|
118999
|
+
return result;
|
|
119000
|
+
}
|
|
119001
|
+
}
|
|
119002
|
+
}
|
|
119003
|
+
}
|
|
119004
|
+
}
|
|
119005
|
+
return undefined;
|
|
119006
|
+
}
|
|
118876
119007
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
118877
119008
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
118878
119009
|
if (normalizedTargetPath === undefined) {
|
|
@@ -118902,7 +119033,15 @@ var ts;
|
|
|
118902
119033
|
var moduleFileNameForExtensionless = void 0;
|
|
118903
119034
|
while (true) {
|
|
118904
119035
|
// If the module could be imported by a directory name, use that directory's name
|
|
118905
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119036
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119037
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119038
|
+
if (blockedByExports) {
|
|
119039
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119040
|
+
}
|
|
119041
|
+
if (verbatimFromExports) {
|
|
119042
|
+
return moduleFileToTry;
|
|
119043
|
+
}
|
|
119044
|
+
}
|
|
118906
119045
|
if (packageRootPath) {
|
|
118907
119046
|
moduleSpecifier = packageRootPath;
|
|
118908
119047
|
isPackageRootPath = true;
|
|
@@ -118939,6 +119078,15 @@ var ts;
|
|
|
118939
119078
|
var moduleFileToTry = path;
|
|
118940
119079
|
if (host.fileExists(packageJsonPath)) {
|
|
118941
119080
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119081
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119082
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119083
|
+
if (fromExports) {
|
|
119084
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119085
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119086
|
+
}
|
|
119087
|
+
if (packageJsonContent.exports) {
|
|
119088
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119089
|
+
}
|
|
118942
119090
|
var versionPaths = packageJsonContent.typesVersions
|
|
118943
119091
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
118944
119092
|
: undefined;
|
|
@@ -561,7 +561,7 @@
|
|
|
561
561
|
"Duplicate_property_0_2718": "重复的属性 \"{0}\"。",
|
|
562
562
|
"Dynamic_import_cannot_have_type_arguments_1326": "动态导入不能含有类型参数。",
|
|
563
563
|
"Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "动态导入的说明符类型必须是 \"string\",但此处类型是 \"{0}\"。",
|
|
564
|
-
"
|
|
564
|
+
"Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "仅当 '--module' 标志设置为 'es2020'、'es2022'、'esnext'、 'commonjs'、'amd'、'system'、'umd'、'node12' 或 'nodenext' 时,才支持动态导入。",
|
|
565
565
|
"Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "动态导入只能接受模块说明符和可选断言作为参数",
|
|
566
566
|
"Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324": "只有在 \"--module\" 选项设置为 \"esnext\" 时,动态导入才支持第二个参数。",
|
|
567
567
|
"Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_2762": "联合类型 \"{0}\" 的每个成员都有构造签名,但这些签名都不能互相兼容。",
|
|
@@ -1360,7 +1360,7 @@
|
|
|
1360
1360
|
"The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "全局类型 \"JSX.{0}\" 不可具有多个属性。",
|
|
1361
1361
|
"The_implementation_signature_is_declared_here_2750": "在此处声明实现签名。",
|
|
1362
1362
|
"The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470": "将生成到 CommonJS 输出的文件中不允许 'import.meta' 元属性。",
|
|
1363
|
-
"
|
|
1363
|
+
"The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343": "仅当 '--module' 选项为 'es2020'、'es2022'、'esnext'、 'system'、'node12' 或 'nodenext' 时,才允许 'import.meta' 元属性。",
|
|
1364
1364
|
"The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "如果没有引用 \"{1}\",则无法命名 \"{0}\" 的推断类型。这很可能不可移植。需要类型注释。",
|
|
1365
1365
|
"The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "推断类型“{0}”引用的类型具有无法简单序列化的循环结构。必须具有类型注释。",
|
|
1366
1366
|
"The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "“{0}”的推断类型引用不可访问的“{1}”类型。需要类型批注。",
|
|
@@ -1459,9 +1459,9 @@
|
|
|
1459
1459
|
"This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "此语法需要一个导入的帮助程序,但找不到模块“{0}”。",
|
|
1460
1460
|
"This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此语法需要名为 \"{1}\" 的导入帮助器,\"{0}\" 中不存在该帮助器。请考虑升级 \"{0}\" 的版本。",
|
|
1461
1461
|
"This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此语法需要一个名为 \"{1}\" 且包含 {2} 参数的导入帮助程序,该帮助程序与 \"{0}\" 中的相应帮助程序不兼容。请考虑升级 \"{0}\" 的版本。",
|
|
1462
|
-
"
|
|
1462
|
+
"Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "仅当 'module' 选项设置为 'es2022'、'esnext'、'system' 或 'nodenext',且 'target' 选项设置为 'es2017' 或更高版本时,才允许顶级 'await' 表达式。",
|
|
1463
1463
|
"Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 文件中的顶级声明必须以 \"declare\" 或 \"export\" 修饰符开头。",
|
|
1464
|
-
"
|
|
1464
|
+
"Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "仅当 'module' 选项设置为 'es2022'、'esnext'、'system' 或 'nodenext',且 'target' 选项设置为 'es2017' 或更高版本时,才允许顶级 'for await' 循环。",
|
|
1465
1465
|
"Trailing_comma_not_allowed_1009": "不允许使用尾随逗号。",
|
|
1466
1466
|
"Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153": "将每个文件转换为单独的模块(类似 \"ts.transpileModule\")。",
|
|
1467
1467
|
"Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035": "尝试使用 `npm i --save-dev @types/{1}` (如果存在),或者添加一个包含 `declare module '{0}';` 的新声明(.d.ts)文件",
|
|
@@ -561,7 +561,7 @@
|
|
|
561
561
|
"Duplicate_property_0_2718": "屬性 '{0}' 重複。",
|
|
562
562
|
"Dynamic_import_cannot_have_type_arguments_1326": "動態匯入不可有型別引數。",
|
|
563
563
|
"Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "動態匯入的指定名稱必須屬於類型 'string',但這裡的類型為 '{0}'。",
|
|
564
|
-
"
|
|
564
|
+
"Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "只有在 '--module' 旗標設定為 'es2020'、'es2022'、'esnext'、'commonjs'、'amd'、'system'、'umd'、'node12' 或 'nodenext',才支援動態匯入。",
|
|
565
565
|
"Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "動態匯入只能接受模組指定名稱和選擇性判斷提示來做為引數",
|
|
566
566
|
"Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324": "當 '--module' 選項設定為 'esnext' 時,動態匯入只支援第二個引數。",
|
|
567
567
|
"Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_2762": "等位型別 '{0}' 的每個成員都有建構簽章,但這些簽章都互不相容。",
|
|
@@ -1360,7 +1360,7 @@
|
|
|
1360
1360
|
"The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "全域類型 'JSX.{0}' 的屬性不得超過一個。",
|
|
1361
1361
|
"The_implementation_signature_is_declared_here_2750": "實作簽章宣告於此處。",
|
|
1362
1362
|
"The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470": "將會組建至 CommonJS 輸出的檔案中不允許 'import.meta' 中繼屬性。",
|
|
1363
|
-
"
|
|
1363
|
+
"The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343": "只有當 '--module' 選項為 'es2020'、'es2022'、'esnext'、'system'、, 'node12' 或 'nodenext' 時,才允許 'import.meta' 中繼屬性。",
|
|
1364
1364
|
"The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "'{0}' 的推斷類型無法在沒有 '{1}' 參考的情況下命名。其可能非可攜式。必須有型別註解。",
|
|
1365
1365
|
"The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "'{0}' 的推斷型別參考了具有迴圈結構且不是可完整序列化的型別。必須有型別註解。",
|
|
1366
1366
|
"The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "'{0}' 的推斷型別參考了無法存取的 '{1}' 型別。必須有型別註解。",
|
|
@@ -1459,9 +1459,9 @@
|
|
|
1459
1459
|
"This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "此語法需要已匯入的協助程式,但找不到模組 '{0}'。",
|
|
1460
1460
|
"This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此語法需要名為 '{1}' 的已匯入協助程式,但其不存在於 '{0}' 中。請考慮升級您的 '{0}' 版本。",
|
|
1461
1461
|
"This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此語法需要名為 '{1}' 且具有 {2} 參數的匯入協助程式,其與 '{0}' 中的參數不相容。請考慮升級 '{0}' 的版本。",
|
|
1462
|
-
"
|
|
1462
|
+
"Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "只有在 'module' 選項設定為 'es2022'、'esnext'、'system' 或 'nodenext',而且 'target' 選項設定為 'es2017' 或更高版本時,才允許最上層的 'await' 運算式。",
|
|
1463
1463
|
"Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 檔案中的最上層宣告必須以 'declare' 或 'export' 修飾元開頭。",
|
|
1464
|
-
"
|
|
1464
|
+
"Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "只有在 'module' 選項設為 'es2022'、'esnext'、'system' 或 'nodenext',而且 'target' 選項設為 'es2017' 或更高版本時,才允許最上層的 'for await' 迴圈。",
|
|
1465
1465
|
"Trailing_comma_not_allowed_1009": "尾端不得為逗號。",
|
|
1466
1466
|
"Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153": "以個別模組的形式轉換每個檔案的語言 (類似於 'ts.transpileModule')。",
|
|
1467
1467
|
"Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035": "如有 `npm i --save-dev @types/{1}`,請嘗試使用,或新增包含 `declare module '{0}';` 的宣告 (.d.ts) 檔案",
|
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": "4.5.0-dev.
|
|
5
|
+
"version": "4.5.0-dev.20211002",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|