-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Auto-imports with NodeNext + isolatedModules missing type qualifier for decorated types #54717
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
The settings you specified definitely have no inherent problem with the code example you gave. That would be an error under |
Related: #54664 |
I can reproduce the error by running tsc. I'll figure out a real repro. |
@andrewbranch Wait, this is not an error under isolatedModules? That doesn’t seem right… my understanding was, isolatedModules is supposed to error if correct emit requires type info from another file—which it does here, in order to know it has to erase the import. |
It doesn’t require type info, because |
Okay sorry for the confusion. The issue is specifically one for decorators, not everything. I was clouded by the all-or-nothing approach of figuring out a way to get this auto-fixed, by pulling in eslint to just be consistent about all such imports (any that could do Here's the exact diagnostic that is emitted, if you don't
|
This only seems to be an error with NodeNext (or maybe NodeNext + esm) and isolatedModules, and TS server's import suggestion chooses |
I tried making a codesandbox, but I wasn't able to reproduce it there. Event in my local project, I'm staring at two very similar decorated class properties, and TS is only emitting this error for one of them 🤔 |
Is the one that’s not erroring referencing a class, and one that’s erroring referencing an interface/type? 😄 I recall adding that error for decorator metadata, and I probably didn’t adjust auto-imports accordingly. It is a bug, but the fact that it’s decorator metadata makes it pretty edge-casey in my opinion. If it were specific to |
👍 yep I think that's why! Okay cool; we use sequelize-typescript, so we get a lot of mileage out of decorators, which is why we saw this everywhere 😅 |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
It's happening in 5.1.3, but it's surely been present since the 4.x version where
"moduleResolution": "NodeNext"
was supported.💻 Code
See example below. The tsconfig should have the following configuration:
🙁 Actual behavior
When typing out the code on the last line and accepting the suggested import, you get the following import:
This import won't compile with this TS project configuration.
🙂 Expected behavior
Instead, you should get an import like this, since explicit type imports are required (compiler error) when
isolatedModules
is set totrue
, whenmoduleResolution
is set toNodeNext
and using decorators.Today, the workaround is to use an eslint rule to help auto-fix these issues.
The text was updated successfully, but these errors were encountered: