Skip to content

Anonymous class with static crashes compiler in ES2015 target #10024

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

Closed
mihailik opened this issue Jul 29, 2016 · 3 comments
Closed

Anonymous class with static crashes compiler in ES2015 target #10024

mihailik opened this issue Jul 29, 2016 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@mihailik
Copy link
Contributor

TypeScript Version: npm typescript@next 2.1.0

Code

(class { static x = 0; })

Expected behavior:

Not crash compiler

Actual behavior:

Crashes during compilation:

***>node ***\typescript\lib\tsc.js cl.ts -t ES2015
***\typescript\lib\tsc.js:36955
                throw e;
                ^

TypeError: Cannot read property 'id' of undefined
    at Object.getNodeId (***\typescript\lib\tsc.js:13033:18)
    at getGeneratedNameForNode (***\typescript\lib\tsc.js:30048:29)
    at emitClassLikeDeclarationForES6AndHigher (***\typescript\lib\tsc.js:33600:37)
    at emitClassLikeDeclaration (***\typescript\lib\tsc.js:33558:21)
    at emitClassExpression (***\typescript\lib\tsc.js:33548:24)
    at emitJavaScriptWorker (***\typescript\lib\tsc.js:35657:32)
    at emitNodeWithoutSourceMap (***\typescript\lib\tsc.js:35465:21)
    at emitNodeWithSourceMap (***\typescript\lib\tsc.js:35459:21)
    at emitNodeConsideringCommentsOption (***\typescript\lib\tsc.js:35450:21)
    at emit (***\typescript\lib\tsc.js:35433:17)

This could be related to #9969 Support emitting static properties for classes with no name

Also note that #9969 seems to imply polluting the global namespace with mangled variable names in ES2015 mode. I was trying to test that, and stumbled upon the crash.

@ghost ghost self-assigned this Jul 29, 2016
@ghost
Copy link

ghost commented Jul 29, 2016

Looks like a duplicate of #9966. Could you try using the very latest tsc (node node_modules/typescript/lib/tsc.js --version should be Version 2.1.0-dev.20160729)?

@mihailik
Copy link
Contributor Author

Absolutely true, thanks @Andy-MS -- it is indeed a duplicate, and the latest 20160729 fixes it.

Yes, the global scope is polluted — but I can see you've opened a separate issue, thanks! 👍

@mihailik
Copy link
Contributor Author

BTW, I didn't realise using that thumbs-up icon closes the issue. But nevermind, it's a duplicate and needs to be closed anyway.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 29, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants