Skip to content

feat(create-vite): set types compiler option in tsconfigs#20132

Merged
sapphi-red merged 4 commits into
mainfrom
arnaud/create-vite-tsconfig-types
Sep 22, 2025
Merged

feat(create-vite): set types compiler option in tsconfigs#20132
sapphi-red merged 4 commits into
mainfrom
arnaud/create-vite-tsconfig-types

Conversation

@ArnaudBarre
Copy link
Copy Markdown
Member

It will be the default in the next tsc --init, and I think we should do too. See #20131 for impact once the codebase grows.

The shared config in the vue template already sets it.

I updated the svelte one to include previous changes (isolatedModules is implied by the bundler mode in the shared config)

@ArnaudBarre ArnaudBarre self-assigned this May 29, 2025
@ArnaudBarre ArnaudBarre changed the title fix(create-vite): set types compiler option in tsconfigs feat(create-vite): set types compiler option in tsconfigs May 29, 2025
@sapphi-red sapphi-red added the feat: create-vite create-vite package label May 30, 2025
@sapphi-red
Copy link
Copy Markdown
Member

This could be confusing for beginners as I guess most articles expect types to be not set, but maybe it's fine as the vue template sets it.

We should remove / replace this part.

**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.

@ArnaudBarre
Copy link
Copy Markdown
Member Author

Ah yeah if we do that we can have types: ["vite/client"] in app tsconfigs and remove the extra vite-env.d.ts file

@sapphi-red
Copy link
Copy Markdown
Member

Now that TS 5.9 is released with the new tsc --init, I think we can move this one forward.

@ArnaudBarre
Copy link
Copy Markdown
Member Author

What do you think about removing vite-env.d.ts in favor of types: ["vite/client"]
I personally always used the later because it's one less file and don't use a syntax arcane syntax

@sapphi-red
Copy link
Copy Markdown
Member

sapphi-red commented Aug 8, 2025

Ah, yeah, that makes sense.
I think we should also update this part of the document to move the types field approach up and put the reference one in the ::: details.
https://vite.dev/guide/features.html#client-types

@ArnaudBarre
Copy link
Copy Markdown
Member Author

I'll update the PR soon

@ArnaudBarre ArnaudBarre force-pushed the arnaud/create-vite-tsconfig-types branch 2 times, most recently from 59ae74d to 9e6de6c Compare August 10, 2025 08:11
@ArnaudBarre ArnaudBarre requested review from sapphi-red and removed request for sapphi-red August 10, 2025 08:16
Comment thread docs/guide/features.md Outdated
Comment thread packages/create-vite/template-svelte-ts/tsconfig.app.json Outdated
@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Aug 11, 2025
sapphi-red
sapphi-red previously approved these changes Aug 11, 2025
Copy link
Copy Markdown
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

hi-ogawa
hi-ogawa previously approved these changes Aug 11, 2025
Comment thread docs/guide/api-hmr.md Outdated
Comment thread docs/guide/features.md Outdated
Comment thread packages/create-vite/template-svelte-ts/tsconfig.app.json Outdated
@sapphi-red sapphi-red linked an issue Aug 27, 2025 that may be closed by this pull request
4 tasks
@ArnaudBarre ArnaudBarre dismissed stale reviews from hi-ogawa and sapphi-red via b30db80 August 30, 2025 13:42
@ArnaudBarre ArnaudBarre force-pushed the arnaud/create-vite-tsconfig-types branch from a7bb86a to b30db80 Compare August 30, 2025 13:42
@ArnaudBarre ArnaudBarre requested a review from sapphi-red August 30, 2025 13:42
@sapphi-red sapphi-red added this to the 7.2 milestone Aug 31, 2025
@sapphi-red sapphi-red removed this from the 7.2 milestone Sep 22, 2025
@sapphi-red sapphi-red merged commit 52469c3 into main Sep 22, 2025
19 checks passed
@sapphi-red sapphi-red deleted the arnaud/create-vite-tsconfig-types branch September 22, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feat: create-vite create-vite package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants