Skip to content
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

fix: revert tsconfig change, fix types #11908

Merged
merged 1 commit into from Mar 6, 2024
Merged

fix: revert tsconfig change, fix types #11908

merged 1 commit into from Mar 6, 2024

Conversation

dummdidumm
Copy link
Member

The inclusion of svelte.config.js is a breaking change since it's type-checked now and that can break projects which did type-check without errors previously
closes #11906

Also relaxes the report-uri types, fully qualified urls are also ok
closes #11905


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Feb 27, 2024

🦋 Changeset detected

Latest commit: 16b5ec0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

The inclusion of `svelte.config.js` is a breaking change since it's type-checked now and that can break projects which did type-check without errors previously
closes #11906

Also relaxes the report-uri types, fully qualified urls are also ok
closes #11905
@benmccann
Copy link
Member

The workaround for this bug is pretty nasty. You can't extend include, which means that a user has to put this in their tsconfig.json:

	"include": [
		"./svelte-kit/ambient.d.ts",
		"./svelte-kit/non-ambient.d.ts",
		"./svelte-kit/types/**/$types.d.ts",
		"svelte.config.js",
		"vite.config.js",
		"vite.config.ts",
		"src/**/*.js",
		"src/**/*.ts",
		"src/**/*.svelte",
		"tests/**/*.js",
		"tests/**/*.ts",
		"tests/**/*.svelte"
	],

I'd be inclined to just fix the CSP types and see if it's still giving folks trouble to include svelte.config.js. While it could be considered a bit of a breaking change to include it, it could also be considered a bug fix as we shouldn't have overlooked it and omitted it in the first place.

@benmccann
Copy link
Member

benmccann commented Feb 27, 2024

I should mention also that the thing that drove #11886 was trying to upgrade a large project to Svelte 5. The project has a ton of createEventDispatcher usage and it turned into a real mess trying to migrate to component props because TypeScript can't differentiate between functions returning void vs Promise<void>. There are, however, several typescript-eslint rules that help enforce proper usage of promises. However, enabling these rules becomes a lot more difficult if #11886 is reverted and I'm afraid that will make it much more of a headache for people to migrate their projects to Svelte 5. Currently the lint rules will only catch issues in the script block. I filed sveltejs/eslint-plugin-svelte#691 to request catching issues in the markup as well.

@AdrianGonz97
Copy link
Contributor

If the tsconfig change is reverted, perhaps an alternative for now (until the next major version) would be to adjust the create-svelte template to include a // @ts-check at the top of the svelte.config.js file? This change should be OK since it'll only affect new projects.

@benmccann
Copy link
Member

While that would help the Svelte config file get type checked, it doesn't seem likely to fix the issue I'm trying to address which is that you can't set recommended-type-checked today because the eslint and tsconfig point to different sets of files

@MathiasWP
Copy link
Contributor

The workaround for this bug is pretty nasty. You can't extend include, which means that a user has to put this in their tsconfig.json:

	"include": [
		"./svelte-kit/ambient.d.ts",
		"./svelte-kit/non-ambient.d.ts",
		"./svelte-kit/types/**/$types.d.ts",
		"svelte.config.js",
		"vite.config.js",
		"vite.config.ts",
		"src/**/*.js",
		"src/**/*.ts",
		"src/**/*.svelte",
		"tests/**/*.js",
		"tests/**/*.ts",
		"tests/**/*.svelte"
	],

I'd be inclined to just fix the CSP types and see if it's still giving folks trouble to include svelte.config.js. While it could be considered a bit of a breaking change to include it, it could also be considered a bug fix as we shouldn't have overlooked it and omitted it in the first place.

IMO fixing the CSP rules is a good compromise. I don't have any problems with the svelte config file being type-checked, i only had problems with incorrect types.

@dummdidumm
Copy link
Member Author

Still strongly in favor of reverting this for 2.0 and looking at it again in 3.0

@dummdidumm dummdidumm merged commit 873a09e into main Mar 6, 2024
13 checks passed
@dummdidumm dummdidumm deleted the tsconfig-revert branch March 6, 2024 11:40
@github-actions github-actions bot mentioned this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants