You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed in Nuxt that auto-import for TypeScript enums was not working, so I reported it to Nuxt #25311 but as @manniL mentioned in that issue, this is an upstream bug with unimport itself so I am opening the issue here. I am not familiar with unimport or how it works and I wasn't able to get an example up and running with it but I do have a Nuxt reproduction and I hope that helps.
Here is the issue - I have a TypeScript enum in common/types/user.ts and I want to use this enum in my app. (see Stackblitz reproduction). And it gets auto-imported by Nuxt but it seems to do it wrongly. Because if I manually import it myself it works (typechecker does not complain). But if I let Nuxt auto-import do it then then typechecker is throwing this error:
$ npm run typecheck
> vue-tsc --noEmit
app.vue:9:23 - error TS2749: 'User' refers to a value, but is being used as a type here. Did you mean 'typeof User'?
9 const myFunc = (user: User) => {
~~~~
Found 1 error in app.vue:9
If I add the import manually then typechecker does not complain 🤷🏻♂️
import{User}from'./common/types/user';
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
martinszeltins
changed the title
Auto-import for enum is not working
Auto-import for enum is not working: TS2749: 'User' refers to a value, but is being used as a type
Jan 20, 2024
Environment
Environment:
Stackblitz
👈️Reproduction
https://stackblitz.com/edit/github-68jxaq?file=package.json,app.vue
Describe the bug
I noticed in Nuxt that auto-import for TypeScript enums was not working, so I reported it to Nuxt #25311 but as @manniL mentioned in that issue, this is an upstream bug with
unimport
itself so I am opening the issue here. I am not familiar withunimport
or how it works and I wasn't able to get an example up and running with it but I do have a Nuxt reproduction and I hope that helps.Here is the issue - I have a TypeScript enum in
common/types/user.ts
and I want to use this enum in my app. (see Stackblitz reproduction). And it gets auto-imported by Nuxt but it seems to do it wrongly. Because if I manually import it myself it works (typechecker does not complain). But if I let Nuxt auto-import do it then then typechecker is throwing this error:nuxt.config.ts:
user.ts:
app.vue
If I add the import manually then typechecker does not complain 🤷🏻♂️
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: