TypeScript
ts/isolated-modules
A Vite project's tsconfig sets isolatedModules or verbatimModuleSyntax, so code the bundler compiles file by file type-checks the same way.
minorstaticfe-typescript
Why
Vite (through esbuild or Oxc) compiles each file alone and never type-checks. Features that need the whole program, such as const enum or an import of a type without type, compile in tsc but break or leave stray imports in the bundle. Without the flag, the editor and tsc stay silent about them.
Fix
Add "verbatimModuleSyntax": true (which implies isolated modules and keeps imports exactly as written) or at least "isolatedModules": true, then write import type { User } from './types' for type-only imports. Run tsc --noEmit (or vue-tsc, svelte-check, astro check) in CI, since the build itself does not check types.
Examples
// bad
{ "compilerOptions": { "module": "esnext", "moduleResolution": "bundler", "strict": true } }
// good
{ "compilerOptions": { "module": "esnext", "moduleResolution": "bundler", "strict": true, "verbatimModuleSyntax": true } }Sources
Facts
- Id
ts/isolated-modules- Severity
- minor
- Check
- static checked in the source by
audit - Applies to
project- Only in projects with
typescriptvite- Taught by the skill
fe-typescriptTypeScript- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain ts/isolated-modules