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

Svelte 5: differentiate between supported and unsupported TypeScript features #11502

Open
Rich-Harris opened this issue May 7, 2024 · 2 comments

Comments

@Rich-Harris
Copy link
Member

Describe the problem

Svelte 5 supports TypeScript syntax natively, but it doesn't support TypeScript runtime features such as enums, using, decorators (related: #11397) and so on.

In general, a good piece of advice is 'don't use these features, they are a bad idea'. TypeScript isn't Babel — in 2024 it should be used for adding types, nothing more. But since not everyone is aware of this distinction or inclined to follow this advice, we need some way of handling these cases.

Describe the proposed solution

The compiler should error when encountering these features with a message that invites people to use the TypeScript preprocessor:

TypeScript decorators are a runtime feature that requires your code to be preprocessed before Svelte compiles it. See https://svelte.dev/docs/... for information on how to set up the preprocessor.

Not 100% sure what this would mean for TypeScript inside markup (or TypeScript that uses these features in .svelte.ts files, for that matter).

Importance

nice to have

@fcrozatier
Copy link
Contributor

Also: ts auto accessor modifier (REPL)

@trueadm trueadm modified the milestones: 5.0, 5.x Jun 3, 2024
@braebo
Copy link
Member

braebo commented Jun 10, 2024

don't use these features, they are a bad idea

These features are robust and widely used across the industry. Decorators are especially useful.

TypeScript isn't Babel

Why is it ok for Svelte to add features when compiling to javascript, but not Typescript?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants