import.meta.glob no longer typed properly
After regenerating the lockfile of my project, my
import.meta.glob
call is now no longer receiving the proper vite-client types.
However they are in the nuxt.d.ts file. Has anyone else run into this?
Error: Property 'glob' does not exist on type 'ImportMeta'.ts-plugin(2339)
3 Replies
Hi @data. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue seems to be related to TypeScript type definitions in Nuxt. Based on the information provided in the knowledge sources, I can offer some insights and potential solutions:
1. The error you're experiencing might be related to recent changes in Nuxt's TypeScript handling. As mentioned in a GitHub pull request (https://github.com/nuxt/nuxt/pull/25266), there have been some fixes related to TypeScript declarations and imports.
2. To ensure you have the latest type definitions, you can try running the following command:
This command generates the necessary TypeScript definition files, including
.nuxt/nuxt.d.ts
, which should contain the types for import.meta.glob
as mentioned in the Nuxt documentation (https://nuxt.com/docs/guide/concepts/typescript#auto-generated-types).
3. Make sure your tsconfig.json
file extends the Nuxt-generated TypeScript configuration:
This step is crucial for ensuring that your project picks up the correct type definitions as described in the Nuxt Bridge documentation (https://nuxt.com/docs/bridge/typescript#update-tsconfigjson).
4. If the issue persists, you might want to check your nuxt.config.ts
file and ensure that TypeScript support is properly configured:
This configuration enables type-checking as mentioned in the Nuxt documentation (https://nuxt.com/docs/guide/concepts/typescript#type-checking).
5. If none of the above solutions work, you might want to consider checking your vue-tsc
version. There have been reports of issues with versions above 2.0.7, as mentioned in a GitHub issue comment (https://github.com/nuxt/nuxt/issues/22421#issuecomment-1679048401). You could try downgrading to version 2.0.7 as a temporary solution.
If these steps don't resolve the issue, it might be worth creating a minimal reproduction of the problem and seeking further assistance from the Nuxt community or reporting it as a potential bug.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@104421158673207296> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
nuxt.d.ts
includes the vite/client