Vite: Templates with tsconfig.json

Created on 14 May 2020  路  2Comments  路  Source: vitejs/vite

Is your feature request related to a problem? Please describe.
Vite supports Typescript, however the documentation says

You must set "isolatedModules": true in your tsconfig.json under compilerOptions so that TS will warn you against the features that do not work with isolated transpilation.

Furthermore, it says

Vite assumes you are targeting modern browsers

Currently, the only way to figure that out is to actually read the documentation in its entirety. It would be greater if the Vite templates were a bit more foolproof and self documenting

Describe the solution you'd like
It'd be great if the Vite templates were to (optionally) come with a tsconfig.json file that targets modern browsers and has all the recommended options set.

Describe alternatives you've considered
The alternative is letting users read the documentation and configure it themselves.

Most helpful comment

You don't need a tsconfig.json to use TS with Vite. It targets esnext by default. The isolatedModules option is just there to help your IDE warn you about usage that won't compile (you'd get the error from vite too when you hit save, but it's nicer to know directly when you are writing it).

Currently, the only way to figure that out is to actually read the documentation in its entirety

The very first section under "Getting Started" is talking about browser support.

All 2 comments

You don't need a tsconfig.json to use TS with Vite. It targets esnext by default. The isolatedModules option is just there to help your IDE warn you about usage that won't compile (you'd get the error from vite too when you hit save, but it's nicer to know directly when you are writing it).

Currently, the only way to figure that out is to actually read the documentation in its entirety

The very first section under "Getting Started" is talking about browser support.

Sorry for beating a dead horse, but without a tsconfig TS will complain about SFC's not being a valid format to use TS in.
Would be good to add something to the docs for this as I assume most people will use SFC's (as they're included in the template anyway).

Was this page helpful?
0 / 5 - 0 ratings