-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[Fix] Disable type checking for non-typescript projects by default #4495
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
Conversation
🦋 Changeset detectedLatest commit: cee9253 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Agree. AFAIK this was changed by accident when the generated tsconfig was introduced, before that the starter template didn't have type checking for JS.
I'm thinking about whether or not we should turn this around and instead have the generated tsconfig contain less (no checkJs for example) and add that to the tsconfig instead when generating a TS project.
I almost wonder if we need to have two separate prompts when setting up a project, where if you don't opt in to TypeScript-the-language you can still opt in to typechecking:
Personally I would choose No and Yes, but I don't know if I'm in a sufficiently small minority that that would be annoying for most non-TypeScript users. |
Users who choose to do that with the todos demo would still get the type errors I mentioned in #4427. I've been suggesting people to add a
That shouldn't be a problem with dynamic prompts, could also consider making it a single selection between, |
I would think that JSdoc users are enough of a minority to justify not introducing an additional prompt for enabling JSdoc. Especially given that the overhead for manually turning it on is literally just flipping one boolean. Also the additional configuration necessary mentioned by @gtm-nayan could mean adding an additional maintenance burden to create-svelte. |
gtm-nayan's suggestion of a single selection between TS, JS and JS with type-checking has my vote. |
I tried my hand at modifying create-svelte to allow for the three way selection favored by gtm-nayan and mrkishi. Edit: how come |
Something like this maybe? Still stuck on the |
I see two possible solutions for the type declarations that wouldn't require a significant overhaul, either we write the type declarations manually and put it inside the appropriate folder under or we include the declarations regardless of I prefer the latter because I think it's better to have declarations if someone decides to flip the Thoughts? |
Another idea is to add JSDoc annotations to the source code, and only strip them out if the user chooses |
Going to close this in favour of #4621 — thanks |
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Ever since #4118 .js files are type checked for newly created projects despite
? Use TypeScript? › No
being selected during the create-svelte wizard.This has been described in #4428 and also causes unwanted error messages as #4427 mentions.
I think type checking for non-typescript projects really should be disabled by default as quite a few newcomers on the discord (today, yesterday) are confused by type errors popping up, even though they didn't select typescript in the CLI.
This behavior seems to surprise even experienced developers: just yesterday Vercel's Lee Robinson stumbled over this in his stream on SvelteKit.
The red squiggly lines on a newly scaffolded out default app also are a bad look IMO.
Maybe we could put a section into the docs for how to re-enable this behavior though? Since it definitely can be helpful when desired.
Closes #4428, closes #4427.
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0