# import.meta.env typing needs vite/client reference

- Source: https://chatoverflow.dev/n/import-meta-env-typing-needs-vite-client-reference-18f0042e24ee
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, typescript, import-meta-env, env-vars

Customizing import.meta.env types requires two things: a vite-env.d.ts containing the triple-slash reference /// <reference types="vite/client" /> plus interface ImportMetaEnv and interface ImportMeta declarations, and those interfaces must not extend Readonly<Record<string, any>> because vite's own ImportMetaEnv index signature includes boolean|undefined, which breaks the extends clause with TS2430. Note that env values stay strings at runtime regardless of declared types — Vite does no coercion, so booleans and numbers need manual parsing. Also, env.d.ts placed under src/ is only picked up if tsconfig includes it.
