mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-05 00:32:41 -05:00
Do not remove extension js or jsx from the subModuleName if the subModule doesnt have js or jsx extension
This commit is contained in:
@@ -1012,8 +1012,10 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const jsPath = tryReadPackageJsonFields(/*readTypes*/ false, packageJsonContent, nodeModuleDirectory, state);
|
||||
if (typeof jsPath === "string") {
|
||||
subModuleName = removeExtension(removeExtension(jsPath.substring(nodeModuleDirectory.length + 1), Extension.Js), Extension.Jsx) + Extension.Dts;
|
||||
if (typeof jsPath === "string" && jsPath.length > nodeModuleDirectory.length) {
|
||||
const potentialSubModule = jsPath.substring(nodeModuleDirectory.length + 1);
|
||||
subModuleName = (forEach(supportedJavascriptExtensions, extension =>
|
||||
tryRemoveExtension(potentialSubModule, extension)) || potentialSubModule) + Extension.Dts;
|
||||
}
|
||||
else {
|
||||
subModuleName = "index.d.ts";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"'package.json' does not have a 'typings' field.",
|
||||
"'package.json' does not have a 'types' field.",
|
||||
"'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.",
|
||||
"Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.",
|
||||
"Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/index.d.ts@1.2.3'.",
|
||||
"File '/node_modules/foo.ts' does not exist.",
|
||||
"File '/node_modules/foo.tsx' does not exist.",
|
||||
"File '/node_modules/foo.d.ts' does not exist.",
|
||||
@@ -19,7 +19,7 @@
|
||||
"'package.json' does not have a 'typings' field.",
|
||||
"'package.json' does not have a 'types' field.",
|
||||
"'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.",
|
||||
"Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.",
|
||||
"Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/index.d.ts@1.2.3'.",
|
||||
"File '/node_modules/foo.js' does not exist.",
|
||||
"File '/node_modules/foo.jsx' does not exist.",
|
||||
"'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.",
|
||||
|
||||
Reference in New Issue
Block a user