Skip to content

Anonymous class with static crashes compiler in ES2015 target #10024

Closed
@mihailik

Description

@mihailik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions