Skip to content
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

tsc emits invalid code for class expression assigned to a reserved word property #26325

Closed
pablobirukov opened this issue Aug 9, 2018 · 2 comments · Fixed by #39684
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@pablobirukov
Copy link

TypeScript Version: 3.1.0-dev.20180809, 3.0.1

Search Terms:
Unexpected token, reserved keyword

Code

({
    for: class { },
    default: class { }
})

Expected behavior:
Emits code with valid identifiers

Actual behavior:
Emits code with invalid identifiers

({
    for: /** @class */ (function () {
        function for() {
//               ~~~ Cannot use the keyword 'for' as a function name
        }
...

Playground Link:

Related Issues:

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 9, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.1 milestone Aug 9, 2018
@RyanCavanaugh
Copy link
Member

Should prefix the function names with _ in this case

@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
4 participants