feat(create-app): add 'vanilla-ts' template#2849
Conversation
| "compilerOptions": { | ||
| "target": "ESNext", | ||
| "module": "ESNext", | ||
| "moduleResolution": "node", |
There was a problem hiding this comment.
Think we should add "lib": ["esnext", "dom"],. It should not conflict with target I think
There was a problem hiding this comment.
I'm fine with that!
To the best of my knowledge (just opened a PR on the subject, so should have confirmation soon): Dropping "lib" results in a default value being used, controlled by "target" -- in this case, since "target" is "ESNext", "lib" will be set to "ESNext.Full" -- which cannot be set directly.
"ESNext.Full" is (currently, it's a moving target) the equivalent of:
["esnext", "dom", "webworker.importscripts", "scripthost", "dom.iterable"]
But perhaps using "lib" is friendlier, since the behavior is more obvious?
There was a problem hiding this comment.
Yeah, I think specifying lib could be more explicit. Where we also have it for Vue TS
There was a problem hiding this comment.
@antfu, yup, all of the template tsconfig.json have "lib", except for for the template-svelte-ts tsconfig.json, been considering floating the idea of making them a little more consistent. Obviously some of the differences are necessary, but others seem arbitrary.
|
Just for reference, a PR to add a vanilla-ts was not merged #2023 (comment), on the basis that it was just adding a config file over the js equivalent. But this is something that several people in the community have been requesting. I think there is merit in having this template in create-app |
|
As #2023 comes first, let's work on it and have discussions there instead. Thanks for your contributions. |
Sounds good, thanks! |
Description
Adds a 'vanilla-ts' template to
@vitejs/create-app.Additional context
After experimenting with this template locally, I discovered a duplicate PR, #2814. I began reviewing it (and subsequently finished reviewing it), but decided it would be slightly more straightforward to open this PR.
I copied
main.jsfrom thevanillatemplate and renamed itmain.ts. I had to make a small change to satisfy Typescript, as the original version:... Throws an
Object is possibly 'null'error.I looked at all of the existing
packages/create-app/template-*/tsconfig.jsonfiles, and came up with atsconfig.jsonfor this template which (hopefully) represents a reasonable starting point. I opted to not specifylib, and instead allow it to be set bytarget(which is also the case in thetemplate-svelte-tstsconfig.json).What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).