mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-21 21:49:12 -06:00
tryGetModuleNameAsNodeModule: Ignore file extension (#24774)
This commit is contained in:
parent
5138b4744d
commit
3822e3e4ed
@ -248,7 +248,7 @@ namespace ts.moduleSpecifiers {
|
||||
const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
||||
if (mainFileRelative) {
|
||||
const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
||||
if (mainExportFile === getCanonicalFileName(path)) {
|
||||
if (removeFileExtension(mainExportFile) === removeFileExtension(getCanonicalFileName(path))) {
|
||||
return packageRootPath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,15 +15,8 @@
|
||||
// @Filename: node_modules/package-name/package.json
|
||||
//// { "main": "bin/lib/libfile.js" }
|
||||
|
||||
|
||||
// In this case, importing the module by its package name:
|
||||
// import { f1 } from 'package-name'
|
||||
// could in theory work, however the resulting code compiles with a module resolution error
|
||||
// since bin/lib/libfile.d.ts isn't declared under "typings" in package.json
|
||||
// Therefore just import the module by its qualified path
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { f1 } from "package-name/bin/lib/libfile";
|
||||
`import { f1 } from "package-name";
|
||||
|
||||
f1('');`
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user