@typescript-deploys/pr-build 4.5.0-pr-46071-13 → 4.5.0-pr-46218-4
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/cs/diagnosticMessages.generated.json +4 -4
- package/lib/es/diagnosticMessages.generated.json +4 -4
- package/lib/fr/diagnosticMessages.generated.json +4 -4
- package/lib/pl/diagnosticMessages.generated.json +4 -4
- package/lib/ru/diagnosticMessages.generated.json +4 -4
- package/lib/tr/diagnosticMessages.generated.json +4 -4
- package/lib/tsc.js +92 -25
- package/lib/tsserver.js +115 -29
- package/lib/tsserverlibrary.js +115 -29
- package/lib/typescript.js +110 -26
- package/lib/typescriptServices.js +110 -26
- package/lib/typingsInstaller.js +107 -26
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -4
- package/package.json +1 -1
package/lib/typescript.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-insiders.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20211005";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -42671,9 +42671,11 @@ var ts;
|
|
|
42671
42671
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42672
42672
|
}
|
|
42673
42673
|
ts.parsePackageName = parsePackageName;
|
|
42674
|
+
/* @internal */
|
|
42674
42675
|
function allKeysStartWithDot(obj) {
|
|
42675
42676
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42676
42677
|
}
|
|
42678
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42677
42679
|
function noKeyStartsWithDot(obj) {
|
|
42678
42680
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42679
42681
|
}
|
|
@@ -42880,17 +42882,19 @@ var ts;
|
|
|
42880
42882
|
}
|
|
42881
42883
|
return toSearchResult(/*value*/ undefined);
|
|
42882
42884
|
}
|
|
42883
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42884
|
-
if (conditions.indexOf("types") === -1)
|
|
42885
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42886
|
-
if (!ts.startsWith(key, "types@"))
|
|
42887
|
-
return false;
|
|
42888
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42889
|
-
if (!range)
|
|
42890
|
-
return false;
|
|
42891
|
-
return range.test(ts.version);
|
|
42892
|
-
}
|
|
42893
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;
|
|
42894
42898
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42895
42899
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42896
42900
|
}
|
|
@@ -61642,7 +61646,8 @@ var ts;
|
|
|
61642
61646
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61643
61647
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61644
61648
|
if (!type.declaration.nameType) {
|
|
61645
|
-
|
|
61649
|
+
var constraint = void 0;
|
|
61650
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61646
61651
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61647
61652
|
}
|
|
61648
61653
|
if (isGenericTupleType(t)) {
|
|
@@ -63034,10 +63039,6 @@ var ts;
|
|
|
63034
63039
|
}
|
|
63035
63040
|
}
|
|
63036
63041
|
message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
|
|
63037
|
-
var typeLengthLimit = 30;
|
|
63038
|
-
if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
|
|
63039
|
-
message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
|
|
63040
|
-
}
|
|
63041
63042
|
}
|
|
63042
63043
|
}
|
|
63043
63044
|
else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
|
|
@@ -63047,15 +63048,6 @@ var ts;
|
|
|
63047
63048
|
}
|
|
63048
63049
|
reportError(message, generalizedSourceType, targetType);
|
|
63049
63050
|
}
|
|
63050
|
-
/** Move a printed type to be on its own line if it is longer than 30 characters */
|
|
63051
|
-
function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
|
|
63052
|
-
var message = diagnostic.message;
|
|
63053
|
-
if (source.length > typeLengthLimit)
|
|
63054
|
-
message = message.replace(" '{0}' ", ":\n{0}\n\n");
|
|
63055
|
-
if (target.length > typeLengthLimit)
|
|
63056
|
-
message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
|
|
63057
|
-
return __assign(__assign({}, diagnostic), { message: message });
|
|
63058
|
-
}
|
|
63059
63051
|
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
|
|
63060
63052
|
var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
|
|
63061
63053
|
var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
|
|
@@ -119146,6 +119138,78 @@ var ts;
|
|
|
119146
119138
|
}
|
|
119147
119139
|
}
|
|
119148
119140
|
}
|
|
119141
|
+
var MatchingMode;
|
|
119142
|
+
(function (MatchingMode) {
|
|
119143
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
119144
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
119145
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
119146
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
119147
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
119148
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
119149
|
+
if (typeof exports === "string") {
|
|
119150
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
119151
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
119152
|
+
switch (mode) {
|
|
119153
|
+
case 0 /* Exact */:
|
|
119154
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
119155
|
+
return { moduleFileToTry: packageName };
|
|
119156
|
+
}
|
|
119157
|
+
break;
|
|
119158
|
+
case 1 /* Directory */:
|
|
119159
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
119160
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
119161
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
119162
|
+
}
|
|
119163
|
+
break;
|
|
119164
|
+
case 2 /* Pattern */:
|
|
119165
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
119166
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
119167
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
119168
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
119169
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
119170
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119171
|
+
}
|
|
119172
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
119173
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
119174
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119175
|
+
}
|
|
119176
|
+
break;
|
|
119177
|
+
}
|
|
119178
|
+
}
|
|
119179
|
+
else if (Array.isArray(exports)) {
|
|
119180
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
119181
|
+
}
|
|
119182
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
119183
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
119184
|
+
// sub-mappings
|
|
119185
|
+
// 3 cases:
|
|
119186
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
119187
|
+
// * pattern mappings (contains a *)
|
|
119188
|
+
// * exact mappings (no *, does not end with /)
|
|
119189
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
119190
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
119191
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
119192
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
119193
|
+
: 0 /* Exact */;
|
|
119194
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
119195
|
+
});
|
|
119196
|
+
}
|
|
119197
|
+
else {
|
|
119198
|
+
// conditional mapping
|
|
119199
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
119200
|
+
var key = _a[_i];
|
|
119201
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
119202
|
+
var subTarget = exports[key];
|
|
119203
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
119204
|
+
if (result) {
|
|
119205
|
+
return result;
|
|
119206
|
+
}
|
|
119207
|
+
}
|
|
119208
|
+
}
|
|
119209
|
+
}
|
|
119210
|
+
}
|
|
119211
|
+
return undefined;
|
|
119212
|
+
}
|
|
119149
119213
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
119150
119214
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
119151
119215
|
if (normalizedTargetPath === undefined) {
|
|
@@ -119175,7 +119239,15 @@ var ts;
|
|
|
119175
119239
|
var moduleFileNameForExtensionless = void 0;
|
|
119176
119240
|
while (true) {
|
|
119177
119241
|
// If the module could be imported by a directory name, use that directory's name
|
|
119178
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119242
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119243
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119244
|
+
if (blockedByExports) {
|
|
119245
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119246
|
+
}
|
|
119247
|
+
if (verbatimFromExports) {
|
|
119248
|
+
return moduleFileToTry;
|
|
119249
|
+
}
|
|
119250
|
+
}
|
|
119179
119251
|
if (packageRootPath) {
|
|
119180
119252
|
moduleSpecifier = packageRootPath;
|
|
119181
119253
|
isPackageRootPath = true;
|
|
@@ -119212,6 +119284,15 @@ var ts;
|
|
|
119212
119284
|
var moduleFileToTry = path;
|
|
119213
119285
|
if (host.fileExists(packageJsonPath)) {
|
|
119214
119286
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119287
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119288
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119289
|
+
if (fromExports) {
|
|
119290
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119291
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119292
|
+
}
|
|
119293
|
+
if (packageJsonContent.exports) {
|
|
119294
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119295
|
+
}
|
|
119215
119296
|
var versionPaths = packageJsonContent.typesVersions
|
|
119216
119297
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
119217
119298
|
: undefined;
|
|
@@ -138732,6 +138813,7 @@ var ts;
|
|
|
138732
138813
|
return false;
|
|
138733
138814
|
}
|
|
138734
138815
|
}
|
|
138816
|
+
Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
|
|
138735
138817
|
})(Rename = ts.Rename || (ts.Rename = {}));
|
|
138736
138818
|
})(ts || (ts = {}));
|
|
138737
138819
|
/* @internal */
|
|
@@ -160028,6 +160110,8 @@ var ts;
|
|
|
160028
160110
|
synchronizeHostData();
|
|
160029
160111
|
var sourceFile = getValidSourceFile(fileName);
|
|
160030
160112
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
160113
|
+
if (!ts.Rename.nodeIsEligibleForRename(node))
|
|
160114
|
+
return undefined;
|
|
160031
160115
|
if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
|
|
160032
160116
|
var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
|
|
160033
160117
|
return [openingElement, closingElement].map(function (node) {
|
|
@@ -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-insiders.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20211005";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -42671,9 +42671,11 @@ var ts;
|
|
|
42671
42671
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42672
42672
|
}
|
|
42673
42673
|
ts.parsePackageName = parsePackageName;
|
|
42674
|
+
/* @internal */
|
|
42674
42675
|
function allKeysStartWithDot(obj) {
|
|
42675
42676
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42676
42677
|
}
|
|
42678
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42677
42679
|
function noKeyStartsWithDot(obj) {
|
|
42678
42680
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42679
42681
|
}
|
|
@@ -42880,17 +42882,19 @@ var ts;
|
|
|
42880
42882
|
}
|
|
42881
42883
|
return toSearchResult(/*value*/ undefined);
|
|
42882
42884
|
}
|
|
42883
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42884
|
-
if (conditions.indexOf("types") === -1)
|
|
42885
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42886
|
-
if (!ts.startsWith(key, "types@"))
|
|
42887
|
-
return false;
|
|
42888
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42889
|
-
if (!range)
|
|
42890
|
-
return false;
|
|
42891
|
-
return range.test(ts.version);
|
|
42892
|
-
}
|
|
42893
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;
|
|
42894
42898
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42895
42899
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42896
42900
|
}
|
|
@@ -61642,7 +61646,8 @@ var ts;
|
|
|
61642
61646
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61643
61647
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61644
61648
|
if (!type.declaration.nameType) {
|
|
61645
|
-
|
|
61649
|
+
var constraint = void 0;
|
|
61650
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61646
61651
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61647
61652
|
}
|
|
61648
61653
|
if (isGenericTupleType(t)) {
|
|
@@ -63034,10 +63039,6 @@ var ts;
|
|
|
63034
63039
|
}
|
|
63035
63040
|
}
|
|
63036
63041
|
message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
|
|
63037
|
-
var typeLengthLimit = 30;
|
|
63038
|
-
if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
|
|
63039
|
-
message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
|
|
63040
|
-
}
|
|
63041
63042
|
}
|
|
63042
63043
|
}
|
|
63043
63044
|
else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
|
|
@@ -63047,15 +63048,6 @@ var ts;
|
|
|
63047
63048
|
}
|
|
63048
63049
|
reportError(message, generalizedSourceType, targetType);
|
|
63049
63050
|
}
|
|
63050
|
-
/** Move a printed type to be on its own line if it is longer than 30 characters */
|
|
63051
|
-
function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
|
|
63052
|
-
var message = diagnostic.message;
|
|
63053
|
-
if (source.length > typeLengthLimit)
|
|
63054
|
-
message = message.replace(" '{0}' ", ":\n{0}\n\n");
|
|
63055
|
-
if (target.length > typeLengthLimit)
|
|
63056
|
-
message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
|
|
63057
|
-
return __assign(__assign({}, diagnostic), { message: message });
|
|
63058
|
-
}
|
|
63059
63051
|
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
|
|
63060
63052
|
var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
|
|
63061
63053
|
var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
|
|
@@ -119146,6 +119138,78 @@ var ts;
|
|
|
119146
119138
|
}
|
|
119147
119139
|
}
|
|
119148
119140
|
}
|
|
119141
|
+
var MatchingMode;
|
|
119142
|
+
(function (MatchingMode) {
|
|
119143
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
119144
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
119145
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
119146
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
119147
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
119148
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
119149
|
+
if (typeof exports === "string") {
|
|
119150
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
119151
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
119152
|
+
switch (mode) {
|
|
119153
|
+
case 0 /* Exact */:
|
|
119154
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
119155
|
+
return { moduleFileToTry: packageName };
|
|
119156
|
+
}
|
|
119157
|
+
break;
|
|
119158
|
+
case 1 /* Directory */:
|
|
119159
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
119160
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
119161
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
119162
|
+
}
|
|
119163
|
+
break;
|
|
119164
|
+
case 2 /* Pattern */:
|
|
119165
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
119166
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
119167
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
119168
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
119169
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
119170
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119171
|
+
}
|
|
119172
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
119173
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
119174
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
119175
|
+
}
|
|
119176
|
+
break;
|
|
119177
|
+
}
|
|
119178
|
+
}
|
|
119179
|
+
else if (Array.isArray(exports)) {
|
|
119180
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
119181
|
+
}
|
|
119182
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
119183
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
119184
|
+
// sub-mappings
|
|
119185
|
+
// 3 cases:
|
|
119186
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
119187
|
+
// * pattern mappings (contains a *)
|
|
119188
|
+
// * exact mappings (no *, does not end with /)
|
|
119189
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
119190
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
119191
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
119192
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
119193
|
+
: 0 /* Exact */;
|
|
119194
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
119195
|
+
});
|
|
119196
|
+
}
|
|
119197
|
+
else {
|
|
119198
|
+
// conditional mapping
|
|
119199
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
119200
|
+
var key = _a[_i];
|
|
119201
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
119202
|
+
var subTarget = exports[key];
|
|
119203
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
119204
|
+
if (result) {
|
|
119205
|
+
return result;
|
|
119206
|
+
}
|
|
119207
|
+
}
|
|
119208
|
+
}
|
|
119209
|
+
}
|
|
119210
|
+
}
|
|
119211
|
+
return undefined;
|
|
119212
|
+
}
|
|
119149
119213
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
119150
119214
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
119151
119215
|
if (normalizedTargetPath === undefined) {
|
|
@@ -119175,7 +119239,15 @@ var ts;
|
|
|
119175
119239
|
var moduleFileNameForExtensionless = void 0;
|
|
119176
119240
|
while (true) {
|
|
119177
119241
|
// If the module could be imported by a directory name, use that directory's name
|
|
119178
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119242
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119243
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119244
|
+
if (blockedByExports) {
|
|
119245
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119246
|
+
}
|
|
119247
|
+
if (verbatimFromExports) {
|
|
119248
|
+
return moduleFileToTry;
|
|
119249
|
+
}
|
|
119250
|
+
}
|
|
119179
119251
|
if (packageRootPath) {
|
|
119180
119252
|
moduleSpecifier = packageRootPath;
|
|
119181
119253
|
isPackageRootPath = true;
|
|
@@ -119212,6 +119284,15 @@ var ts;
|
|
|
119212
119284
|
var moduleFileToTry = path;
|
|
119213
119285
|
if (host.fileExists(packageJsonPath)) {
|
|
119214
119286
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119287
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119288
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119289
|
+
if (fromExports) {
|
|
119290
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119291
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119292
|
+
}
|
|
119293
|
+
if (packageJsonContent.exports) {
|
|
119294
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119295
|
+
}
|
|
119215
119296
|
var versionPaths = packageJsonContent.typesVersions
|
|
119216
119297
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
119217
119298
|
: undefined;
|
|
@@ -138732,6 +138813,7 @@ var ts;
|
|
|
138732
138813
|
return false;
|
|
138733
138814
|
}
|
|
138734
138815
|
}
|
|
138816
|
+
Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
|
|
138735
138817
|
})(Rename = ts.Rename || (ts.Rename = {}));
|
|
138736
138818
|
})(ts || (ts = {}));
|
|
138737
138819
|
/* @internal */
|
|
@@ -160028,6 +160110,8 @@ var ts;
|
|
|
160028
160110
|
synchronizeHostData();
|
|
160029
160111
|
var sourceFile = getValidSourceFile(fileName);
|
|
160030
160112
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
160113
|
+
if (!ts.Rename.nodeIsEligibleForRename(node))
|
|
160114
|
+
return undefined;
|
|
160031
160115
|
if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
|
|
160032
160116
|
var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
|
|
160033
160117
|
return [openingElement, closingElement].map(function (node) {
|
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-insiders.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20211005";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -42466,9 +42466,11 @@ var ts;
|
|
|
42466
42466
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42467
42467
|
}
|
|
42468
42468
|
ts.parsePackageName = parsePackageName;
|
|
42469
|
+
/* @internal */
|
|
42469
42470
|
function allKeysStartWithDot(obj) {
|
|
42470
42471
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42471
42472
|
}
|
|
42473
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42472
42474
|
function noKeyStartsWithDot(obj) {
|
|
42473
42475
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42474
42476
|
}
|
|
@@ -42675,17 +42677,19 @@ var ts;
|
|
|
42675
42677
|
}
|
|
42676
42678
|
return toSearchResult(/*value*/ undefined);
|
|
42677
42679
|
}
|
|
42678
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42679
|
-
if (conditions.indexOf("types") === -1)
|
|
42680
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42681
|
-
if (!ts.startsWith(key, "types@"))
|
|
42682
|
-
return false;
|
|
42683
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42684
|
-
if (!range)
|
|
42685
|
-
return false;
|
|
42686
|
-
return range.test(ts.version);
|
|
42687
|
-
}
|
|
42688
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;
|
|
42689
42693
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42690
42694
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42691
42695
|
}
|
|
@@ -61437,7 +61441,8 @@ var ts;
|
|
|
61437
61441
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61438
61442
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61439
61443
|
if (!type.declaration.nameType) {
|
|
61440
|
-
|
|
61444
|
+
var constraint = void 0;
|
|
61445
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61441
61446
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61442
61447
|
}
|
|
61443
61448
|
if (isGenericTupleType(t)) {
|
|
@@ -62829,10 +62834,6 @@ var ts;
|
|
|
62829
62834
|
}
|
|
62830
62835
|
}
|
|
62831
62836
|
message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
|
|
62832
|
-
var typeLengthLimit = 30;
|
|
62833
|
-
if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
|
|
62834
|
-
message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
|
|
62835
|
-
}
|
|
62836
62837
|
}
|
|
62837
62838
|
}
|
|
62838
62839
|
else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
|
|
@@ -62842,15 +62843,6 @@ var ts;
|
|
|
62842
62843
|
}
|
|
62843
62844
|
reportError(message, generalizedSourceType, targetType);
|
|
62844
62845
|
}
|
|
62845
|
-
/** Move a printed type to be on its own line if it is longer than 30 characters */
|
|
62846
|
-
function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
|
|
62847
|
-
var message = diagnostic.message;
|
|
62848
|
-
if (source.length > typeLengthLimit)
|
|
62849
|
-
message = message.replace(" '{0}' ", ":\n{0}\n\n");
|
|
62850
|
-
if (target.length > typeLengthLimit)
|
|
62851
|
-
message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
|
|
62852
|
-
return __assign(__assign({}, diagnostic), { message: message });
|
|
62853
|
-
}
|
|
62854
62846
|
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
|
|
62855
62847
|
var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
|
|
62856
62848
|
var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
|
|
@@ -118941,6 +118933,78 @@ var ts;
|
|
|
118941
118933
|
}
|
|
118942
118934
|
}
|
|
118943
118935
|
}
|
|
118936
|
+
var MatchingMode;
|
|
118937
|
+
(function (MatchingMode) {
|
|
118938
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
118939
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
118940
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
118941
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
118942
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
118943
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
118944
|
+
if (typeof exports === "string") {
|
|
118945
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
118946
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
118947
|
+
switch (mode) {
|
|
118948
|
+
case 0 /* Exact */:
|
|
118949
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
118950
|
+
return { moduleFileToTry: packageName };
|
|
118951
|
+
}
|
|
118952
|
+
break;
|
|
118953
|
+
case 1 /* Directory */:
|
|
118954
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
118955
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
118956
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
118957
|
+
}
|
|
118958
|
+
break;
|
|
118959
|
+
case 2 /* Pattern */:
|
|
118960
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
118961
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
118962
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
118963
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
118964
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
118965
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118966
|
+
}
|
|
118967
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
118968
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
118969
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118970
|
+
}
|
|
118971
|
+
break;
|
|
118972
|
+
}
|
|
118973
|
+
}
|
|
118974
|
+
else if (Array.isArray(exports)) {
|
|
118975
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
118976
|
+
}
|
|
118977
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
118978
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
118979
|
+
// sub-mappings
|
|
118980
|
+
// 3 cases:
|
|
118981
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
118982
|
+
// * pattern mappings (contains a *)
|
|
118983
|
+
// * exact mappings (no *, does not end with /)
|
|
118984
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
118985
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
118986
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
118987
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
118988
|
+
: 0 /* Exact */;
|
|
118989
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
118990
|
+
});
|
|
118991
|
+
}
|
|
118992
|
+
else {
|
|
118993
|
+
// conditional mapping
|
|
118994
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
118995
|
+
var key = _a[_i];
|
|
118996
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
118997
|
+
var subTarget = exports[key];
|
|
118998
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
118999
|
+
if (result) {
|
|
119000
|
+
return result;
|
|
119001
|
+
}
|
|
119002
|
+
}
|
|
119003
|
+
}
|
|
119004
|
+
}
|
|
119005
|
+
}
|
|
119006
|
+
return undefined;
|
|
119007
|
+
}
|
|
118944
119008
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
118945
119009
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
118946
119010
|
if (normalizedTargetPath === undefined) {
|
|
@@ -118970,7 +119034,15 @@ var ts;
|
|
|
118970
119034
|
var moduleFileNameForExtensionless = void 0;
|
|
118971
119035
|
while (true) {
|
|
118972
119036
|
// If the module could be imported by a directory name, use that directory's name
|
|
118973
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119037
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119038
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119039
|
+
if (blockedByExports) {
|
|
119040
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119041
|
+
}
|
|
119042
|
+
if (verbatimFromExports) {
|
|
119043
|
+
return moduleFileToTry;
|
|
119044
|
+
}
|
|
119045
|
+
}
|
|
118974
119046
|
if (packageRootPath) {
|
|
118975
119047
|
moduleSpecifier = packageRootPath;
|
|
118976
119048
|
isPackageRootPath = true;
|
|
@@ -119007,6 +119079,15 @@ var ts;
|
|
|
119007
119079
|
var moduleFileToTry = path;
|
|
119008
119080
|
if (host.fileExists(packageJsonPath)) {
|
|
119009
119081
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119082
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119083
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119084
|
+
if (fromExports) {
|
|
119085
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119086
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119087
|
+
}
|
|
119088
|
+
if (packageJsonContent.exports) {
|
|
119089
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119090
|
+
}
|
|
119010
119091
|
var versionPaths = packageJsonContent.typesVersions
|
|
119011
119092
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
119012
119093
|
: undefined;
|