Skip to content

emitter crashes with computed object literal names #8532

@jrieken

Description

@jrieken

TypeScript Version:

1.8.x

Code

// A self-contained demonstration of the problem follows...
function createDefaultProperties(): { [name: string]: any } {

    const startTime = Date.now();
    let eventCounter = 0;

    return {
        get ['common.sequenceId']() { return eventCounter++; },
        get timestamp() { return new Date(); },
        get ['common.timesincesessionstart']() { return Date.now() - startTime; }
    };
}
  • open playground website
  • paste code above
  • it crashes like so:
Object {stack: "TypeError: Cannot read property 'declarations' of …script/common/lib/typescriptServices.js:19:13310)", message: "TypeError: Cannot read property 'declarations' of undefined"}
message
:
"TypeError: Cannot read property 'declarations' of undefined"
stack
:
"TypeError: Cannot read property 'declarations' of undefined↵    at e.checkNode (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:1:30909)↵    at t.e._checkNodeOrToken (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:2107)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1801)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at r (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:10966)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:14002)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1824)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at a (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:11081)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:13310)"
__proto__
:
Object

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions