-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(create-app): add 'vanilla-ts' template #2849
Conversation
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "node", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we should add "lib": ["esnext", "dom"],
. It should not conflict with target I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think specifying lib
could be more explicit. Where we also have it for Vue TS
"lib": ["esnext", "dom"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.js
from thevanilla
template 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.json
files, and came up with atsconfig.json
for 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-ts
tsconfig.json
).What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).