microsoft / microsoft/TypeScript
Experimental Decorators don't work in `export` statements
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: JavaScript + ESNext
Search Terms: export+experimental+decorators+export
Code
export default
@x
class A {
}
[❌ ] The above does not work.
@x
class A {}
export default A;
[👌 ] It does work when going with the old syntax, that is splitting export statement and class expression. I.e. this works fine:
Expected behavior:
The syntax should be valid, according to @babel/plugin-proposal-decorators, which is also in line with tc39, as discussed here.
Actual behavior:
The first @ raises:
Expression expected. ts(1109)
Playground Link:
Related Issues:
I previously posted on VSCode issues and was sent here:
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.
Research direction
Start with the linked TypeScript Playground and compare the failing export default @x class A {} example with the working split declaration. Trace how the compiler handles decorators before exported classes, then add coverage showing the expected syntax is accepted without regressing the existing form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100