-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: typescript decorations not compatible with tsconfig.json required for runes to work in classes #11339
Comments
That's not the case anymore in typescript 5 for Stage 3 decorators. Here's what the announcement says:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Note: This bug report has nothing to do with using runes in conjunction with decorations, but rather using decorations at all anywhere in the entire codebase.
This is a fairly low priority bug, if it could even be considered a bug, but given that decorations will become more popular pretty soon as they are gradually integrated into browsers, it may be worth giving some forethought. It's also possible that this is purely a typescript problem and nothing really Svelte can or should do about it.
Decorations require the
experimentalDecorators
in tsconfig.json. However,useDefineForClassFields
needs to be set tofalse
intsconfig.json
in order for them to work.On the other hand, in order for runes to work in any file,
useDefineForClassFields
needs to be set totrue
- which is the default.This creates a situation where either A) no runes work or B) no decorators work (at least field property decorators). This has nothing to do with them being used in the same class or file. It's codebase-wide.
Reproduction
Reproduction requires fiddling with
tsconfig.json
so reproduction in REPL is not possible AFAIK. Fortunately it's simple to do. Just import the followingmy-class.ts
andstate.svelte.ts
into the app."Default mode"
my-class.ts
state.svelte.ts
"Decorator mode"
my-class.ts
state.svelte.ts
Logs
Here is the piped typescript output from the compilation with
useDefineForClassFields
set tofalse
. You can see typescript decides to put the initialisers in the constructor, which breaks$state
.System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: