Skip to content

Experimental Decorators don't work in export statementsΒ #39596

Open
@Domiii

Description

@Domiii

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:

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn idea for TypeScriptWaiting for TC39Unactionable until TC39 reaches some conclusion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions