@@ -5651,7 +5651,7 @@ var ts;
5651
5651
}
5652
5652
var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state);
5653
5653
if (resolvedFromFile) {
5654
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path ) : undefined;
5654
+ var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
5655
5655
var packageId = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, failedLookupLocations, false, state).packageId;
5656
5656
return withPackageId(packageId, resolvedFromFile);
5657
5657
}
@@ -5668,8 +5668,8 @@ var ts;
5668
5668
return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson);
5669
5669
}
5670
5670
var nodeModulesPathPart = "/node_modules/";
5671
- function parseNodeModuleFromPath(path ) {
5672
- path = ts.normalizePath(path);
5671
+ function parseNodeModuleFromPath(resolved ) {
5672
+ var path = ts.normalizePath(resolved. path);
5673
5673
var idx = path.lastIndexOf(nodeModulesPathPart);
5674
5674
if (idx === -1) {
5675
5675
return undefined;
@@ -5680,16 +5680,24 @@ var ts;
5680
5680
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
5681
5681
}
5682
5682
var packageDirectory = path.slice(0, indexAfterPackageName);
5683
- var subModuleName = removeExtensionAndIndex (path.slice(indexAfterPackageName + 1)) ;
5683
+ var subModuleName = ts.removeExtension (path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" ;
5684
5684
return { packageDirectory: packageDirectory, subModuleName: subModuleName };
5685
5685
}
5686
5686
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
5687
5687
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
5688
5688
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
5689
5689
}
5690
- function removeExtensionAndIndex(path) {
5691
- var noExtension = ts.removeFileExtension(path);
5692
- return noExtension === "index" ? "" : ts.removeSuffix(noExtension, "/index");
5690
+ function addExtensionAndIndex(path) {
5691
+ if (path === "") {
5692
+ return "index.d.ts";
5693
+ }
5694
+ if (ts.endsWith(path, ".d.ts")) {
5695
+ return path;
5696
+ }
5697
+ if (ts.endsWith(path, "/index")) {
5698
+ return path + ".d.ts";
5699
+ }
5700
+ return path + "/index.d.ts";
5693
5701
}
5694
5702
function directoryProbablyExists(directoryName, host) {
5695
5703
return !host.directoryExists || host.directoryExists(directoryName);
@@ -5764,12 +5772,30 @@ var ts;
5764
5772
var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
5765
5773
return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state);
5766
5774
}
5767
- function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a ) {
5768
- var host = _a .host, traceEnabled = _a .traceEnabled;
5775
+ function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, state ) {
5776
+ var host = state .host, traceEnabled = state .traceEnabled;
5769
5777
var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host);
5770
5778
var packageJsonPath = pathToPackageJson(nodeModuleDirectory);
5771
5779
if (directoryExists && host.fileExists(packageJsonPath)) {
5772
5780
var packageJsonContent = readJson(packageJsonPath, host);
5781
+ if (subModuleName === "") {
5782
+ var path = tryReadPackageJsonFields(true, packageJsonContent, nodeModuleDirectory, state);
5783
+ if (typeof path === "string") {
5784
+ subModuleName = addExtensionAndIndex(path.substring(nodeModuleDirectory.length + 1));
5785
+ }
5786
+ else {
5787
+ var jsPath = tryReadPackageJsonFields(false, packageJsonContent, nodeModuleDirectory, state);
5788
+ if (typeof jsPath === "string") {
5789
+ subModuleName = ts.removeExtension(ts.removeExtension(jsPath.substring(nodeModuleDirectory.length + 1), ".js"), ".jsx") + ".d.ts";
5790
+ }
5791
+ else {
5792
+ subModuleName = "index.d.ts";
5793
+ }
5794
+ }
5795
+ }
5796
+ if (!ts.endsWith(subModuleName, ".d.ts")) {
5797
+ subModuleName = addExtensionAndIndex(subModuleName);
5798
+ }
5773
5799
var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
5774
5800
? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
5775
5801
: undefined;
@@ -61990,11 +62016,23 @@ var ts;
61990
62016
if (options.noEmit) {
61991
62017
return false;
61992
62018
}
61993
- return ts.forEachEmittedFile(getEmitHost(), function (_a) {
61994
- var jsFilePath = _a.jsFilePath, declarationFilePath = _a.declarationFilePath;
61995
- return isSameFile(jsFilePath, file) ||
61996
- (declarationFilePath && isSameFile(declarationFilePath, file));
61997
- });
62019
+ var filePath = toPath(file);
62020
+ if (getSourceFileByPath(filePath)) {
62021
+ return false;
62022
+ }
62023
+ var out = options.outFile || options.out;
62024
+ if (out) {
62025
+ return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
62026
+ }
62027
+ if (options.outDir) {
62028
+ return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
62029
+ }
62030
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
62031
+ var filePathWithoutExtension = ts.removeFileExtension(filePath);
62032
+ return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts")) ||
62033
+ !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx"));
62034
+ }
62035
+ return false;
61998
62036
}
61999
62037
function isSameFile(file1, file2) {
62000
62038
return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
@@ -91753,7 +91791,8 @@ var ts;
91753
91791
}
91754
91792
var logger = createLogger();
91755
91793
var sys = ts.sys;
91756
- var useWatchGuard = process.platform === "win32" && ts.getNodeMajorVersion() >= 4;
91794
+ var nodeVersion = ts.getNodeMajorVersion();
91795
+ var useWatchGuard = process.platform === "win32" && nodeVersion >= 4;
91757
91796
var originalWatchDirectory = sys.watchDirectory.bind(sys);
91758
91797
var noopWatcher = { close: ts.noop };
91759
91798
function watchDirectorySwallowingException(path, callback, recursive) {
@@ -91889,8 +91928,9 @@ var ts;
91889
91928
allowLocalPluginLoads: allowLocalPluginLoads
91890
91929
};
91891
91930
logger.info("Starting TS Server");
91892
- logger.info("Version: " + ts.versionMajorMinor );
91931
+ logger.info("Version: " + ts.version );
91893
91932
logger.info("Arguments: " + process.argv.join(" "));
91933
+ logger.info("Platform: " + os.platform() + " NodeVersion: " + nodeVersion + " CaseSensitive: " + sys.useCaseSensitiveFileNames);
91894
91934
var ioSession = new IOSession(options);
91895
91935
process.on("uncaughtException", function (err) {
91896
91936
ioSession.logError(err, "unknown");
0 commit comments