Vite: Usage of import.meta.hot types

Created on 19 Jun 2020  路  3Comments  路  Source: vitejs/vite

Is your feature request related to a problem? Please describe.
Currently vite has types for import.meta.hot. However, they are not picked up by default when creating a project that uses them (Visual Studio Code, Vetur).

The error message is Property 'hot' does not exist on type 'ImportMeta'.

Describe the solution you'd like
It'd be great if the types were picked up automatically or the documentation documented what you have to add to your tsconfig.json

Describe alternatives you've considered
Currently a workaround is to copy-paste the file in question to your project.

Most helpful comment

It's expected for this.By the way,you also can do it by use tsconfig.json and add vite into types inside of compilerOptions option.

All 3 comments

You can just do import 'vite/hmr'

It's worth looking into make it work by default for sure

I haven't been able to get it to work out of the box, however, importing vite does work :tm:.

Simply using import "vite" throws an error [vite] Failed to resolve module import "vite/dist/index.js.map". (imported by /@modules/vite/dist/index.js) at runtime.

But, using the type-imports, it works quite fine

import type {} from "vite";

It's expected for this.By the way,you also can do it by use tsconfig.json and add vite into types inside of compilerOptions option.

Was this page helpful?
0 / 5 - 0 ratings