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

feat: allow generated tsconfig to be modified #8606

Merged
merged 4 commits into from
Jan 26, 2023
Merged

feat: allow generated tsconfig to be modified #8606

merged 4 commits into from
Jan 26, 2023

Conversation

Rich-Harris
Copy link
Member

closes #6868, closes #8237

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:.
@changeset-bot
Copy link

changeset-bot bot commented Jan 19, 2023

🦋 Changeset detected

Latest commit: f991ec3

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 Minor

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

@benmccann
Copy link
Member

I believe this won't be necessary with TypeScript 5 due out in March because if I'm remembering correctly it will allow you to extend from multiple tsconfigs. I feel like that might be the preferable solution though it would require making users wait two months.

@Rich-Harris
Copy link
Member Author

Interesting. I guess it comes down to whether there are other things beyond extends that people might need to change (though if the answer is 'no' then maybe we should have just merged #8237 instead...)

@benmccann
Copy link
Member

If the user has to change things I think that's fine. They can decide whether they want to upgrade and if they care about extending multiple tsconfigs then they can do that.

I think it would become more problematic if there were things in SvelteKit that needed to be changed to allow you to run TypeScript 5. As far as I can tell, thus far we're probably safe and SvelteKit should work with TS 4 or 5: https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes. npm run check runs successfully against the demo project with TypeScript 5.0.0-dev.20230119

@Rich-Harris
Copy link
Member Author

Rich-Harris commented Jan 19, 2023

The question is 'aside from extends, is there something in the generated tsconfig.json that someone might have a reason to change?' — unrelated to TypeScript 4 vs 5

@Rich-Harris Rich-Harris marked this pull request as draft January 20, 2023 15:43
@Rich-Harris
Copy link
Member Author

Marked this as draft because it probably makes sense to wait until TypeScript 5 if extends is the only reason to need this ability, rather than expanding configuration surface area. If we discover other use cases in the meantime, we can undraft it.

Until then, there's a workaround, so no-one is blocked on this even if it's a little inconvenient: manually copy the monorepo config into packages.

@baisong
Copy link

baisong commented Jan 24, 2023

Clarifying question, is this related to this typescript note from the (experimental) svelte-package docs?

Setting "moduleResolution": "NodeNext" in your tsconfig.json or jsconfig.json will help you with [adhering to Node's ESM algorithm].

Mentioning because I've recently been modifying the default jsconfig.json, tsconfig.json and .svelte-kit/tsconfig.json while troubleshooting using svelte-package to publish a component library npm module.

I noticed that, even when "moduleResolution": "NodeNext" is present in all three files, svelte-package always overwrites the autogenerated .svelte-kit/tsconfig.json to be "moduleResolution": "node".

@Rich-Harris
Copy link
Member Author

@baisong that's unrelated to this PR/issue — this is purely about the contents of .svelte-kit/tsconfig.json

@anthonator
Copy link

I'd be curious if this feature would solve an issue we're currently having.

When extending the @typescript-eslint/recommended-requiring-type-checking eslint config we get the following error.

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/svelte.config.ts` using `parserOptions.project`: <tsconfigRootDir>/../../../../../users/tyranthosaur/projects/imable/ui/tsconfig.json

We've tried adding ./svelte.config.ts to the include property in the project root's tsconfig.json but unfortunately this performs an override instead of a merge of the include from ./.svelte-kit/tsconfig.json. We got around this issue by creating a tsconfig.eslint.json with an include property we copy/pasted from ./.svelte-kit/tsconfig.json. Definitely not ideal.

It seems like this feature would allow people to get around issues like this in a more elegant way.

@Rich-Harris Rich-Harris marked this pull request as ready for review January 25, 2023 22:24
@Rich-Harris
Copy link
Member Author

Yep, that seems like a good enough reason! Marking this PR ready

@dummdidumm dummdidumm merged commit f5b65d9 into master Jan 26, 2023
@dummdidumm dummdidumm deleted the gh-6868 branch January 26, 2023 12:21
@github-actions github-actions bot mentioned this pull request Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants