-
Notifications
You must be signed in to change notification settings - Fork 12.8k
auto-import with package.json#imports
does not take moduleResolution
into account
#60405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think this is a bug. A related comment to this by @andrewbranch : |
Oh, I see. But TypeScript language server does not error if I use the extensionless module specifier either. Why is that the case? |
The thread I linked to specifically calls out extensionless module specifiers as erroring. If they are not then perhaps that is a bug - it might be good to wait for @andrewbranch to chime in. It would be good to understand the difference between that issue and yours. |
@alan910127 your repo link above 404s—did you accidentally make it private? If you share the repo, I’ll investigate. @Andarist is right; the import you listed as your expected behavior should have an error. |
Hi, I'm trying to implement a just in time ui lib in a monorepo. What do u think is the best practice now to implement absolute path resolve inside this pacakge? I'm currently using both package.json subpath import along with compilerOptions.path to surpress the warning. It works fine but I just really wanna keep the logic in one place :) |
🔎 Search Terms
"subpath", "imports", "package.json", "moduleResolution"
🕗 Version & Regression Information
package.json
imports
field #55015⏯ Playground Link
alan910127/ts-60405-repro
💻 Code
🙁 Actual behavior
When auto-importing the function
baz
(either through completion or code action), the typescript language server will insert an import statement with a.js
file extension.🙂 Expected behavior
Since we are using
"moduleResolution": "Bundler"
, it should insert an import statement without the.js
file extension.Additional information about the issue
I've seen a similar issue #59200, but I cannot reproduce the issue, with the same setup. Therefore, I think my issue might be related with the subpath imports.
The text was updated successfully, but these errors were encountered: