@typescript-deploys/pr-build 4.7.0-pr-48997-3 → 4.7.0-pr-48997-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +29 -19
- package/lib/tsserver.js +32 -22
- package/lib/tsserverlibrary.js +32 -22
- package/lib/typescript.js +32 -22
- package/lib/typescriptServices.js +32 -22
- package/lib/typingsInstaller.js +32 -22
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -4242,7 +4242,12 @@ var ts;
|
|
|
4242
4242
|
(!relativeName ||
|
|
4243
4243
|
relativeName === lastDirectoryPart ||
|
|
4244
4244
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
4245
|
-
|
|
4245
|
+
if (inodeWatching) {
|
|
4246
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
4247
|
+
}
|
|
4248
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
4249
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
4250
|
+
}
|
|
4246
4251
|
}
|
|
4247
4252
|
}
|
|
4248
4253
|
function watchPresentFileSystemEntryWithFsWatchFile() {
|
|
@@ -26463,6 +26468,7 @@ var ts;
|
|
|
26463
26468
|
var startPos = scanner.getStartPos();
|
|
26464
26469
|
var result = parseListElement(kind, parseElement);
|
|
26465
26470
|
if (!result) {
|
|
26471
|
+
parsingContext = saveParsingContext;
|
|
26466
26472
|
return undefined;
|
|
26467
26473
|
}
|
|
26468
26474
|
list.push(result);
|
|
@@ -100611,14 +100617,14 @@ var ts;
|
|
|
100611
100617
|
if (options === void 0) { options = {}; }
|
|
100612
100618
|
var info = getInfo(importingSourceFile.path, host);
|
|
100613
100619
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
100614
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, true, options.overrideImportMode); });
|
|
100620
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, true, options.overrideImportMode); });
|
|
100615
100621
|
}
|
|
100616
100622
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
100617
100623
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
100618
100624
|
if (options === void 0) { options = {}; }
|
|
100619
100625
|
var info = getInfo(importingSourceFileName, host);
|
|
100620
100626
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
100621
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode); }) ||
|
|
100627
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) ||
|
|
100622
100628
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
100623
100629
|
}
|
|
100624
100630
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -100684,7 +100690,7 @@ var ts;
|
|
|
100684
100690
|
var relativeSpecifiers;
|
|
100685
100691
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
100686
100692
|
var modulePath = modulePaths_1[_i];
|
|
100687
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode);
|
|
100693
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode);
|
|
100688
100694
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
100689
100695
|
if (specifier && modulePath.isRedirect) {
|
|
100690
100696
|
return nodeModulesSpecifiers;
|
|
@@ -101015,7 +101021,7 @@ var ts;
|
|
|
101015
101021
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
101016
101022
|
: ts.removeFileExtension(relativePath);
|
|
101017
101023
|
}
|
|
101018
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
101024
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
101019
101025
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
101020
101026
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
101021
101027
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -101028,8 +101034,9 @@ var ts;
|
|
|
101028
101034
|
var moduleSpecifier = path;
|
|
101029
101035
|
var isPackageRootPath = false;
|
|
101030
101036
|
if (!packageNameOnly) {
|
|
101037
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
101031
101038
|
var packageRootIndex = parts.packageRootIndex;
|
|
101032
|
-
var
|
|
101039
|
+
var moduleFileName = void 0;
|
|
101033
101040
|
while (true) {
|
|
101034
101041
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
101035
101042
|
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
@@ -101045,11 +101052,11 @@ var ts;
|
|
|
101045
101052
|
isPackageRootPath = true;
|
|
101046
101053
|
break;
|
|
101047
101054
|
}
|
|
101048
|
-
if (!
|
|
101049
|
-
|
|
101055
|
+
if (!moduleFileName)
|
|
101056
|
+
moduleFileName = moduleFileToTry;
|
|
101050
101057
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
101051
101058
|
if (packageRootIndex === -1) {
|
|
101052
|
-
moduleSpecifier =
|
|
101059
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
101053
101060
|
break;
|
|
101054
101061
|
}
|
|
101055
101062
|
}
|
|
@@ -101098,7 +101105,7 @@ var ts;
|
|
|
101098
101105
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
101099
101106
|
}
|
|
101100
101107
|
}
|
|
101101
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
101108
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
101102
101109
|
if (ts.isString(mainFileRelative)) {
|
|
101103
101110
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
101104
101111
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -101106,14 +101113,13 @@ var ts;
|
|
|
101106
101113
|
}
|
|
101107
101114
|
}
|
|
101108
101115
|
}
|
|
101109
|
-
|
|
101110
|
-
|
|
101111
|
-
|
|
101112
|
-
|
|
101113
|
-
|
|
101114
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
101116
|
+
else {
|
|
101117
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
101118
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
101119
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
101120
|
+
}
|
|
101115
101121
|
}
|
|
101116
|
-
return
|
|
101122
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
101117
101123
|
}
|
|
101118
101124
|
}
|
|
101119
101125
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -101134,7 +101140,7 @@ var ts;
|
|
|
101134
101140
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
101135
101141
|
});
|
|
101136
101142
|
}
|
|
101137
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
101143
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
101138
101144
|
if (ts.fileExtensionIsOneOf(fileName, [".json", ".mjs", ".cjs"]))
|
|
101139
101145
|
return fileName;
|
|
101140
101146
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -101142,7 +101148,11 @@ var ts;
|
|
|
101142
101148
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
101143
101149
|
switch (ending) {
|
|
101144
101150
|
case 0:
|
|
101145
|
-
|
|
101151
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
101152
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
101153
|
+
return noExtension;
|
|
101154
|
+
}
|
|
101155
|
+
return withoutIndex;
|
|
101146
101156
|
case 1:
|
|
101147
101157
|
return noExtension;
|
|
101148
101158
|
case 2:
|
package/lib/tsserver.js
CHANGED
|
@@ -6766,7 +6766,12 @@ var ts;
|
|
|
6766
6766
|
(!relativeName ||
|
|
6767
6767
|
relativeName === lastDirectoryPart ||
|
|
6768
6768
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
6769
|
-
|
|
6769
|
+
if (inodeWatching) {
|
|
6770
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6771
|
+
}
|
|
6772
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6773
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6774
|
+
}
|
|
6770
6775
|
}
|
|
6771
6776
|
}
|
|
6772
6777
|
/**
|
|
@@ -32847,6 +32852,7 @@ var ts;
|
|
|
32847
32852
|
var startPos = scanner.getStartPos();
|
|
32848
32853
|
var result = parseListElement(kind, parseElement);
|
|
32849
32854
|
if (!result) {
|
|
32855
|
+
parsingContext = saveParsingContext;
|
|
32850
32856
|
return undefined;
|
|
32851
32857
|
}
|
|
32852
32858
|
list.push(result);
|
|
@@ -121722,14 +121728,14 @@ var ts;
|
|
|
121722
121728
|
if (options === void 0) { options = {}; }
|
|
121723
121729
|
var info = getInfo(importingSourceFile.path, host);
|
|
121724
121730
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121725
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121731
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121726
121732
|
}
|
|
121727
121733
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121728
121734
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121729
121735
|
if (options === void 0) { options = {}; }
|
|
121730
121736
|
var info = getInfo(importingSourceFileName, host);
|
|
121731
121737
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121732
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121738
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121733
121739
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121734
121740
|
}
|
|
121735
121741
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121805,7 +121811,7 @@ var ts;
|
|
|
121805
121811
|
var relativeSpecifiers;
|
|
121806
121812
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
121807
121813
|
var modulePath = modulePaths_1[_i];
|
|
121808
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121814
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121809
121815
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
121810
121816
|
if (specifier && modulePath.isRedirect) {
|
|
121811
121817
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122198,7 +122204,7 @@ var ts;
|
|
|
122198
122204
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122199
122205
|
: ts.removeFileExtension(relativePath);
|
|
122200
122206
|
}
|
|
122201
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122207
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122202
122208
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122203
122209
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122204
122210
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122212,8 +122218,9 @@ var ts;
|
|
|
122212
122218
|
var moduleSpecifier = path;
|
|
122213
122219
|
var isPackageRootPath = false;
|
|
122214
122220
|
if (!packageNameOnly) {
|
|
122221
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122215
122222
|
var packageRootIndex = parts.packageRootIndex;
|
|
122216
|
-
var
|
|
122223
|
+
var moduleFileName = void 0;
|
|
122217
122224
|
while (true) {
|
|
122218
122225
|
// If the module could be imported by a directory name, use that directory's name
|
|
122219
122226
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122230,12 +122237,12 @@ var ts;
|
|
|
122230
122237
|
isPackageRootPath = true;
|
|
122231
122238
|
break;
|
|
122232
122239
|
}
|
|
122233
|
-
if (!
|
|
122234
|
-
|
|
122240
|
+
if (!moduleFileName)
|
|
122241
|
+
moduleFileName = moduleFileToTry;
|
|
122235
122242
|
// try with next level of directory
|
|
122236
122243
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122237
122244
|
if (packageRootIndex === -1) {
|
|
122238
|
-
moduleSpecifier =
|
|
122245
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122239
122246
|
break;
|
|
122240
122247
|
}
|
|
122241
122248
|
}
|
|
@@ -122293,7 +122300,7 @@ var ts;
|
|
|
122293
122300
|
}
|
|
122294
122301
|
}
|
|
122295
122302
|
// If the file is the main module, it can be imported by the package name
|
|
122296
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122303
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122297
122304
|
if (ts.isString(mainFileRelative)) {
|
|
122298
122305
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122299
122306
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122301,17 +122308,14 @@ var ts;
|
|
|
122301
122308
|
}
|
|
122302
122309
|
}
|
|
122303
122310
|
}
|
|
122304
|
-
|
|
122305
|
-
|
|
122306
|
-
|
|
122307
|
-
|
|
122308
|
-
|
|
122309
|
-
|
|
122310
|
-
// IFF there is not _also_ a file by the same name
|
|
122311
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122312
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122311
|
+
else {
|
|
122312
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122313
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122314
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122315
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122316
|
+
}
|
|
122313
122317
|
}
|
|
122314
|
-
return
|
|
122318
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122315
122319
|
}
|
|
122316
122320
|
}
|
|
122317
122321
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122333,7 +122337,7 @@ var ts;
|
|
|
122333
122337
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122334
122338
|
});
|
|
122335
122339
|
}
|
|
122336
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122340
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122337
122341
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122338
122342
|
return fileName;
|
|
122339
122343
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122341,7 +122345,13 @@ var ts;
|
|
|
122341
122345
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122342
122346
|
switch (ending) {
|
|
122343
122347
|
case 0 /* Minimal */:
|
|
122344
|
-
|
|
122348
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122349
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122350
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122351
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122352
|
+
return noExtension;
|
|
122353
|
+
}
|
|
122354
|
+
return withoutIndex;
|
|
122345
122355
|
case 1 /* Index */:
|
|
122346
122356
|
return noExtension;
|
|
122347
122357
|
case 2 /* JsExtension */:
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -6960,7 +6960,12 @@ var ts;
|
|
|
6960
6960
|
(!relativeName ||
|
|
6961
6961
|
relativeName === lastDirectoryPart ||
|
|
6962
6962
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
6963
|
-
|
|
6963
|
+
if (inodeWatching) {
|
|
6964
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6965
|
+
}
|
|
6966
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6967
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6968
|
+
}
|
|
6964
6969
|
}
|
|
6965
6970
|
}
|
|
6966
6971
|
/**
|
|
@@ -33041,6 +33046,7 @@ var ts;
|
|
|
33041
33046
|
var startPos = scanner.getStartPos();
|
|
33042
33047
|
var result = parseListElement(kind, parseElement);
|
|
33043
33048
|
if (!result) {
|
|
33049
|
+
parsingContext = saveParsingContext;
|
|
33044
33050
|
return undefined;
|
|
33045
33051
|
}
|
|
33046
33052
|
list.push(result);
|
|
@@ -121916,14 +121922,14 @@ var ts;
|
|
|
121916
121922
|
if (options === void 0) { options = {}; }
|
|
121917
121923
|
var info = getInfo(importingSourceFile.path, host);
|
|
121918
121924
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121919
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121925
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121920
121926
|
}
|
|
121921
121927
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121922
121928
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121923
121929
|
if (options === void 0) { options = {}; }
|
|
121924
121930
|
var info = getInfo(importingSourceFileName, host);
|
|
121925
121931
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121926
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121932
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121927
121933
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121928
121934
|
}
|
|
121929
121935
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121999,7 +122005,7 @@ var ts;
|
|
|
121999
122005
|
var relativeSpecifiers;
|
|
122000
122006
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
122001
122007
|
var modulePath = modulePaths_1[_i];
|
|
122002
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122008
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122003
122009
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
122004
122010
|
if (specifier && modulePath.isRedirect) {
|
|
122005
122011
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122392,7 +122398,7 @@ var ts;
|
|
|
122392
122398
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122393
122399
|
: ts.removeFileExtension(relativePath);
|
|
122394
122400
|
}
|
|
122395
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122401
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122396
122402
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122397
122403
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122398
122404
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122406,8 +122412,9 @@ var ts;
|
|
|
122406
122412
|
var moduleSpecifier = path;
|
|
122407
122413
|
var isPackageRootPath = false;
|
|
122408
122414
|
if (!packageNameOnly) {
|
|
122415
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122409
122416
|
var packageRootIndex = parts.packageRootIndex;
|
|
122410
|
-
var
|
|
122417
|
+
var moduleFileName = void 0;
|
|
122411
122418
|
while (true) {
|
|
122412
122419
|
// If the module could be imported by a directory name, use that directory's name
|
|
122413
122420
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122424,12 +122431,12 @@ var ts;
|
|
|
122424
122431
|
isPackageRootPath = true;
|
|
122425
122432
|
break;
|
|
122426
122433
|
}
|
|
122427
|
-
if (!
|
|
122428
|
-
|
|
122434
|
+
if (!moduleFileName)
|
|
122435
|
+
moduleFileName = moduleFileToTry;
|
|
122429
122436
|
// try with next level of directory
|
|
122430
122437
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122431
122438
|
if (packageRootIndex === -1) {
|
|
122432
|
-
moduleSpecifier =
|
|
122439
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122433
122440
|
break;
|
|
122434
122441
|
}
|
|
122435
122442
|
}
|
|
@@ -122487,7 +122494,7 @@ var ts;
|
|
|
122487
122494
|
}
|
|
122488
122495
|
}
|
|
122489
122496
|
// If the file is the main module, it can be imported by the package name
|
|
122490
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122497
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122491
122498
|
if (ts.isString(mainFileRelative)) {
|
|
122492
122499
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122493
122500
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122495,17 +122502,14 @@ var ts;
|
|
|
122495
122502
|
}
|
|
122496
122503
|
}
|
|
122497
122504
|
}
|
|
122498
|
-
|
|
122499
|
-
|
|
122500
|
-
|
|
122501
|
-
|
|
122502
|
-
|
|
122503
|
-
|
|
122504
|
-
// IFF there is not _also_ a file by the same name
|
|
122505
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122506
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122505
|
+
else {
|
|
122506
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122507
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122508
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122509
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122510
|
+
}
|
|
122507
122511
|
}
|
|
122508
|
-
return
|
|
122512
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122509
122513
|
}
|
|
122510
122514
|
}
|
|
122511
122515
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122527,7 +122531,7 @@ var ts;
|
|
|
122527
122531
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122528
122532
|
});
|
|
122529
122533
|
}
|
|
122530
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122534
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122531
122535
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122532
122536
|
return fileName;
|
|
122533
122537
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122535,7 +122539,13 @@ var ts;
|
|
|
122535
122539
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122536
122540
|
switch (ending) {
|
|
122537
122541
|
case 0 /* Minimal */:
|
|
122538
|
-
|
|
122542
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122543
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122544
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122545
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122546
|
+
return noExtension;
|
|
122547
|
+
}
|
|
122548
|
+
return withoutIndex;
|
|
122539
122549
|
case 1 /* Index */:
|
|
122540
122550
|
return noExtension;
|
|
122541
122551
|
case 2 /* JsExtension */:
|
package/lib/typescript.js
CHANGED
|
@@ -6960,7 +6960,12 @@ var ts;
|
|
|
6960
6960
|
(!relativeName ||
|
|
6961
6961
|
relativeName === lastDirectoryPart ||
|
|
6962
6962
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
6963
|
-
|
|
6963
|
+
if (inodeWatching) {
|
|
6964
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6965
|
+
}
|
|
6966
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6967
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6968
|
+
}
|
|
6964
6969
|
}
|
|
6965
6970
|
}
|
|
6966
6971
|
/**
|
|
@@ -33041,6 +33046,7 @@ var ts;
|
|
|
33041
33046
|
var startPos = scanner.getStartPos();
|
|
33042
33047
|
var result = parseListElement(kind, parseElement);
|
|
33043
33048
|
if (!result) {
|
|
33049
|
+
parsingContext = saveParsingContext;
|
|
33044
33050
|
return undefined;
|
|
33045
33051
|
}
|
|
33046
33052
|
list.push(result);
|
|
@@ -121916,14 +121922,14 @@ var ts;
|
|
|
121916
121922
|
if (options === void 0) { options = {}; }
|
|
121917
121923
|
var info = getInfo(importingSourceFile.path, host);
|
|
121918
121924
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121919
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121925
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121920
121926
|
}
|
|
121921
121927
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121922
121928
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121923
121929
|
if (options === void 0) { options = {}; }
|
|
121924
121930
|
var info = getInfo(importingSourceFileName, host);
|
|
121925
121931
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121926
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121932
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121927
121933
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121928
121934
|
}
|
|
121929
121935
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121999,7 +122005,7 @@ var ts;
|
|
|
121999
122005
|
var relativeSpecifiers;
|
|
122000
122006
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
122001
122007
|
var modulePath = modulePaths_1[_i];
|
|
122002
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122008
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122003
122009
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
122004
122010
|
if (specifier && modulePath.isRedirect) {
|
|
122005
122011
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122392,7 +122398,7 @@ var ts;
|
|
|
122392
122398
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122393
122399
|
: ts.removeFileExtension(relativePath);
|
|
122394
122400
|
}
|
|
122395
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122401
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122396
122402
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122397
122403
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122398
122404
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122406,8 +122412,9 @@ var ts;
|
|
|
122406
122412
|
var moduleSpecifier = path;
|
|
122407
122413
|
var isPackageRootPath = false;
|
|
122408
122414
|
if (!packageNameOnly) {
|
|
122415
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122409
122416
|
var packageRootIndex = parts.packageRootIndex;
|
|
122410
|
-
var
|
|
122417
|
+
var moduleFileName = void 0;
|
|
122411
122418
|
while (true) {
|
|
122412
122419
|
// If the module could be imported by a directory name, use that directory's name
|
|
122413
122420
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122424,12 +122431,12 @@ var ts;
|
|
|
122424
122431
|
isPackageRootPath = true;
|
|
122425
122432
|
break;
|
|
122426
122433
|
}
|
|
122427
|
-
if (!
|
|
122428
|
-
|
|
122434
|
+
if (!moduleFileName)
|
|
122435
|
+
moduleFileName = moduleFileToTry;
|
|
122429
122436
|
// try with next level of directory
|
|
122430
122437
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122431
122438
|
if (packageRootIndex === -1) {
|
|
122432
|
-
moduleSpecifier =
|
|
122439
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122433
122440
|
break;
|
|
122434
122441
|
}
|
|
122435
122442
|
}
|
|
@@ -122487,7 +122494,7 @@ var ts;
|
|
|
122487
122494
|
}
|
|
122488
122495
|
}
|
|
122489
122496
|
// If the file is the main module, it can be imported by the package name
|
|
122490
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122497
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122491
122498
|
if (ts.isString(mainFileRelative)) {
|
|
122492
122499
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122493
122500
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122495,17 +122502,14 @@ var ts;
|
|
|
122495
122502
|
}
|
|
122496
122503
|
}
|
|
122497
122504
|
}
|
|
122498
|
-
|
|
122499
|
-
|
|
122500
|
-
|
|
122501
|
-
|
|
122502
|
-
|
|
122503
|
-
|
|
122504
|
-
// IFF there is not _also_ a file by the same name
|
|
122505
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122506
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122505
|
+
else {
|
|
122506
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122507
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122508
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122509
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122510
|
+
}
|
|
122507
122511
|
}
|
|
122508
|
-
return
|
|
122512
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122509
122513
|
}
|
|
122510
122514
|
}
|
|
122511
122515
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122527,7 +122531,7 @@ var ts;
|
|
|
122527
122531
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122528
122532
|
});
|
|
122529
122533
|
}
|
|
122530
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122534
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122531
122535
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122532
122536
|
return fileName;
|
|
122533
122537
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122535,7 +122539,13 @@ var ts;
|
|
|
122535
122539
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122536
122540
|
switch (ending) {
|
|
122537
122541
|
case 0 /* Minimal */:
|
|
122538
|
-
|
|
122542
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122543
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122544
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122545
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122546
|
+
return noExtension;
|
|
122547
|
+
}
|
|
122548
|
+
return withoutIndex;
|
|
122539
122549
|
case 1 /* Index */:
|
|
122540
122550
|
return noExtension;
|
|
122541
122551
|
case 2 /* JsExtension */:
|
|
@@ -6960,7 +6960,12 @@ var ts;
|
|
|
6960
6960
|
(!relativeName ||
|
|
6961
6961
|
relativeName === lastDirectoryPart ||
|
|
6962
6962
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
6963
|
-
|
|
6963
|
+
if (inodeWatching) {
|
|
6964
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6965
|
+
}
|
|
6966
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6967
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6968
|
+
}
|
|
6964
6969
|
}
|
|
6965
6970
|
}
|
|
6966
6971
|
/**
|
|
@@ -33041,6 +33046,7 @@ var ts;
|
|
|
33041
33046
|
var startPos = scanner.getStartPos();
|
|
33042
33047
|
var result = parseListElement(kind, parseElement);
|
|
33043
33048
|
if (!result) {
|
|
33049
|
+
parsingContext = saveParsingContext;
|
|
33044
33050
|
return undefined;
|
|
33045
33051
|
}
|
|
33046
33052
|
list.push(result);
|
|
@@ -121916,14 +121922,14 @@ var ts;
|
|
|
121916
121922
|
if (options === void 0) { options = {}; }
|
|
121917
121923
|
var info = getInfo(importingSourceFile.path, host);
|
|
121918
121924
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121919
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121925
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121920
121926
|
}
|
|
121921
121927
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121922
121928
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121923
121929
|
if (options === void 0) { options = {}; }
|
|
121924
121930
|
var info = getInfo(importingSourceFileName, host);
|
|
121925
121931
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121926
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121932
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121927
121933
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121928
121934
|
}
|
|
121929
121935
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121999,7 +122005,7 @@ var ts;
|
|
|
121999
122005
|
var relativeSpecifiers;
|
|
122000
122006
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
122001
122007
|
var modulePath = modulePaths_1[_i];
|
|
122002
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122008
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122003
122009
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
122004
122010
|
if (specifier && modulePath.isRedirect) {
|
|
122005
122011
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122392,7 +122398,7 @@ var ts;
|
|
|
122392
122398
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122393
122399
|
: ts.removeFileExtension(relativePath);
|
|
122394
122400
|
}
|
|
122395
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122401
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122396
122402
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122397
122403
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122398
122404
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122406,8 +122412,9 @@ var ts;
|
|
|
122406
122412
|
var moduleSpecifier = path;
|
|
122407
122413
|
var isPackageRootPath = false;
|
|
122408
122414
|
if (!packageNameOnly) {
|
|
122415
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122409
122416
|
var packageRootIndex = parts.packageRootIndex;
|
|
122410
|
-
var
|
|
122417
|
+
var moduleFileName = void 0;
|
|
122411
122418
|
while (true) {
|
|
122412
122419
|
// If the module could be imported by a directory name, use that directory's name
|
|
122413
122420
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122424,12 +122431,12 @@ var ts;
|
|
|
122424
122431
|
isPackageRootPath = true;
|
|
122425
122432
|
break;
|
|
122426
122433
|
}
|
|
122427
|
-
if (!
|
|
122428
|
-
|
|
122434
|
+
if (!moduleFileName)
|
|
122435
|
+
moduleFileName = moduleFileToTry;
|
|
122429
122436
|
// try with next level of directory
|
|
122430
122437
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122431
122438
|
if (packageRootIndex === -1) {
|
|
122432
|
-
moduleSpecifier =
|
|
122439
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122433
122440
|
break;
|
|
122434
122441
|
}
|
|
122435
122442
|
}
|
|
@@ -122487,7 +122494,7 @@ var ts;
|
|
|
122487
122494
|
}
|
|
122488
122495
|
}
|
|
122489
122496
|
// If the file is the main module, it can be imported by the package name
|
|
122490
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122497
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122491
122498
|
if (ts.isString(mainFileRelative)) {
|
|
122492
122499
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122493
122500
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122495,17 +122502,14 @@ var ts;
|
|
|
122495
122502
|
}
|
|
122496
122503
|
}
|
|
122497
122504
|
}
|
|
122498
|
-
|
|
122499
|
-
|
|
122500
|
-
|
|
122501
|
-
|
|
122502
|
-
|
|
122503
|
-
|
|
122504
|
-
// IFF there is not _also_ a file by the same name
|
|
122505
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122506
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122505
|
+
else {
|
|
122506
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122507
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122508
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122509
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122510
|
+
}
|
|
122507
122511
|
}
|
|
122508
|
-
return
|
|
122512
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122509
122513
|
}
|
|
122510
122514
|
}
|
|
122511
122515
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122527,7 +122531,7 @@ var ts;
|
|
|
122527
122531
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122528
122532
|
});
|
|
122529
122533
|
}
|
|
122530
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122534
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122531
122535
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122532
122536
|
return fileName;
|
|
122533
122537
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122535,7 +122539,13 @@ var ts;
|
|
|
122535
122539
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122536
122540
|
switch (ending) {
|
|
122537
122541
|
case 0 /* Minimal */:
|
|
122538
|
-
|
|
122542
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122543
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122544
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122545
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122546
|
+
return noExtension;
|
|
122547
|
+
}
|
|
122548
|
+
return withoutIndex;
|
|
122539
122549
|
case 1 /* Index */:
|
|
122540
122550
|
return noExtension;
|
|
122541
122551
|
case 2 /* JsExtension */:
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -6755,7 +6755,12 @@ var ts;
|
|
|
6755
6755
|
(!relativeName ||
|
|
6756
6756
|
relativeName === lastDirectoryPart ||
|
|
6757
6757
|
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length))) {
|
|
6758
|
-
|
|
6758
|
+
if (inodeWatching) {
|
|
6759
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6760
|
+
}
|
|
6761
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6762
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6763
|
+
}
|
|
6759
6764
|
}
|
|
6760
6765
|
}
|
|
6761
6766
|
/**
|
|
@@ -32836,6 +32841,7 @@ var ts;
|
|
|
32836
32841
|
var startPos = scanner.getStartPos();
|
|
32837
32842
|
var result = parseListElement(kind, parseElement);
|
|
32838
32843
|
if (!result) {
|
|
32844
|
+
parsingContext = saveParsingContext;
|
|
32839
32845
|
return undefined;
|
|
32840
32846
|
}
|
|
32841
32847
|
list.push(result);
|
|
@@ -121711,14 +121717,14 @@ var ts;
|
|
|
121711
121717
|
if (options === void 0) { options = {}; }
|
|
121712
121718
|
var info = getInfo(importingSourceFile.path, host);
|
|
121713
121719
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121714
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121720
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121715
121721
|
}
|
|
121716
121722
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121717
121723
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121718
121724
|
if (options === void 0) { options = {}; }
|
|
121719
121725
|
var info = getInfo(importingSourceFileName, host);
|
|
121720
121726
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121721
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121727
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121722
121728
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121723
121729
|
}
|
|
121724
121730
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121794,7 +121800,7 @@ var ts;
|
|
|
121794
121800
|
var relativeSpecifiers;
|
|
121795
121801
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
121796
121802
|
var modulePath = modulePaths_1[_i];
|
|
121797
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121803
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121798
121804
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
121799
121805
|
if (specifier && modulePath.isRedirect) {
|
|
121800
121806
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122187,7 +122193,7 @@ var ts;
|
|
|
122187
122193
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122188
122194
|
: ts.removeFileExtension(relativePath);
|
|
122189
122195
|
}
|
|
122190
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122196
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122191
122197
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122192
122198
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122193
122199
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122201,8 +122207,9 @@ var ts;
|
|
|
122201
122207
|
var moduleSpecifier = path;
|
|
122202
122208
|
var isPackageRootPath = false;
|
|
122203
122209
|
if (!packageNameOnly) {
|
|
122210
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122204
122211
|
var packageRootIndex = parts.packageRootIndex;
|
|
122205
|
-
var
|
|
122212
|
+
var moduleFileName = void 0;
|
|
122206
122213
|
while (true) {
|
|
122207
122214
|
// If the module could be imported by a directory name, use that directory's name
|
|
122208
122215
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122219,12 +122226,12 @@ var ts;
|
|
|
122219
122226
|
isPackageRootPath = true;
|
|
122220
122227
|
break;
|
|
122221
122228
|
}
|
|
122222
|
-
if (!
|
|
122223
|
-
|
|
122229
|
+
if (!moduleFileName)
|
|
122230
|
+
moduleFileName = moduleFileToTry;
|
|
122224
122231
|
// try with next level of directory
|
|
122225
122232
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122226
122233
|
if (packageRootIndex === -1) {
|
|
122227
|
-
moduleSpecifier =
|
|
122234
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122228
122235
|
break;
|
|
122229
122236
|
}
|
|
122230
122237
|
}
|
|
@@ -122282,7 +122289,7 @@ var ts;
|
|
|
122282
122289
|
}
|
|
122283
122290
|
}
|
|
122284
122291
|
// If the file is the main module, it can be imported by the package name
|
|
122285
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122292
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122286
122293
|
if (ts.isString(mainFileRelative)) {
|
|
122287
122294
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122288
122295
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122290,17 +122297,14 @@ var ts;
|
|
|
122290
122297
|
}
|
|
122291
122298
|
}
|
|
122292
122299
|
}
|
|
122293
|
-
|
|
122294
|
-
|
|
122295
|
-
|
|
122296
|
-
|
|
122297
|
-
|
|
122298
|
-
|
|
122299
|
-
// IFF there is not _also_ a file by the same name
|
|
122300
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122301
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122300
|
+
else {
|
|
122301
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122302
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122303
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122304
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122305
|
+
}
|
|
122302
122306
|
}
|
|
122303
|
-
return
|
|
122307
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122304
122308
|
}
|
|
122305
122309
|
}
|
|
122306
122310
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122322,7 +122326,7 @@ var ts;
|
|
|
122322
122326
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122323
122327
|
});
|
|
122324
122328
|
}
|
|
122325
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122329
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122326
122330
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122327
122331
|
return fileName;
|
|
122328
122332
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122330,7 +122334,13 @@ var ts;
|
|
|
122330
122334
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122331
122335
|
switch (ending) {
|
|
122332
122336
|
case 0 /* Minimal */:
|
|
122333
|
-
|
|
122337
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122338
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122339
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122340
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122341
|
+
return noExtension;
|
|
122342
|
+
}
|
|
122343
|
+
return withoutIndex;
|
|
122334
122344
|
case 1 /* Index */:
|
|
122335
122345
|
return noExtension;
|
|
122336
122346
|
case 2 /* JsExtension */:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.7.0-pr-48997-
|
|
5
|
+
"version": "4.7.0-pr-48997-6",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|