Open Domiii opened 4 years ago
The decorators implemented in TS are the "experimental" decorators that effectively predate the current TC39 proposal, which has not reached Stage 3 yet.
OP must be working around with Babel: separating the export statement so TS doesn't have an error, then @babel/typescript
can compile it (I'm doing this too).
TypeScript Version: JavaScript + ESNext
Search Terms: export+experimental+decorators+export
Code
[❌ ] The above does not work.
[👌 ] It does work when going with the old syntax, that is splitting
export
statement andclass
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:Playground Link:
https://www.typescriptlang.org/play/?target=99&ts=4.0.0-dev.20200714&useJavaScript=true#code/KYDwDg9gTgLgBAE2AMwIYFcA2MBQABGVAcwAoByYAYwFsBaUMTVASwDtgoyBKfGYaxqj7kAPAmYA3AHwiA9OOncclJgGdVcALIBPAMIQBcUH1YINAZUzNqcAN44AvkA
Related Issues:
I previously posted on VSCode issues and was sent here: