svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Svelte 5: Add the typescript option to svelte.config

Open Xeronic opened this issue 6 months ago • 4 comments

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

Xeronic avatar Dec 04 '23 09:12 Xeronic

+1 @Rich-Harris

Creative-Difficulty avatar Jan 24 '24 17:01 Creative-Difficulty

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.

dummdidumm avatar Apr 19 '24 12:04 dummdidumm

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.

dominikg avatar Apr 19 '24 14:04 dominikg

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

dummdidumm avatar Apr 21 '24 06:04 dummdidumm