sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
80.1k stars 4.26k forks source link

Svelte 5: Add the typescript option to svelte.config #9752

Open Xeronic opened 11 months ago

Xeronic commented 11 months ago

Describe the problem

Having to write lang=ts in every file is a tedious thing and not very svelte.

Describe the proposed solution

To have a global setting in svelte.config to enable it project wide.

Alternatives considered

.

Importance

would make my life easier

Creative-Difficulty commented 10 months ago

+1 @Rich-Harris

dummdidumm commented 7 months ago

We'd like to not make this change inside svelte.config.js even if it sounds like the better place, because we need to load it asynchronously, and many code paths in language tools (ts language service, eslint and prettier up until very recently) require synchronousity. Therefore, IF we do that, I propose to add it to the tsconfig.json instead. We already have a little-known svelteOptions field in there which we use for Svelte Native currently, and we could put it under there. We wouldn't be the first ones to do that; Angular does it, too.

dominikg commented 7 months ago

lang=ts is also used by vite and possibly other tools, we had an effort in svelte-preprocess before and abandoned it because it caused multiple issues.

tsconfig.json is notoriously hard to resolve and means extra work for every .svelte file.

Instead of removing this information from the script tag i propose to make it easier to create new svelte files with the lang=ts already set.

dummdidumm commented 7 months ago

Related: https://github.com/sveltejs/language-tools/tree/master/packages/language-server#sveltepluginsveltedefaultscriptlanguage