microsoft / microsoft/TypeScript
[Decorators] Missing error when calling `addInitializer` after that the decorator is done
Open
@rbuckton is already working on this.
Since Feb 5, 2024.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
decorators addInitializer error
🕗 Version & Regression Information
- This is the behavior in every version I tried since Stage 3 decorators where implemented
⏯ Playground Link
💻 Code
let addInitializerFrom1: DecoratorContext["addInitializer"];
function dec1(_: any, ctx: DecoratorContext) {
addInitializerFrom1 = ctx.addInitializer;
}
function dec2(_: any, _2: any) {
addInitializerFrom1(() => {})
console.log("ADDED")
}
class A {
@dec2
@dec1
foo = 1;
}
🙁 Actual behavior
The addInitializerFrom1 call should throw
🙂 Expected behavior
addInitializerFrom1 doesn't throw
Additional information about the issue
After that dec1 is called, decorationState.[[Finished]] for the decorationState relative to dec1 is set to false and thus calling addInitializer should throw.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.