Skip to content

'const enum' in single statement context crashes compiler #25663

@ajafff

Description

@ajafff

TypeScript Version: 3.0.0-dev.20180712

Search Terms:

Code

if (Boolean())
  const enum Foo {}

Expected behavior:

Some compiler error.

Actual behavior:

TypeError: Cannot read property 'kind' of undefined
    at Object.isBlock (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:9915:21)
    at emitEmbeddedStatement (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:65524:20)
    at emitIfStatement (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:64709:13)
    at pipelineEmitWithHint (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:63854:32)
    at emitNodeWithSourceMap (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:62836:21)
    at pipelineEmitWithSourceMap (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:63726:58)
    at emitNodeWithComments (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:62970:17)
    at pipelineEmitWithComments (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:63718:13)
    at emitNodeWithNotification (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:62486:21)
    at pipelineEmitWithNotification (/Users/klaus/code/wotan/node_modules/typescript/lib/tsc.js:63713:47)

Playground Link: https://agentcooper.github.io/typescript-play/#code/JYMwBAFAQg9jA2BTAhgOwgSgwKDHsAxjKgM4AuYiqArgLZgBicYA3gL5A

Related Issues:

#22682 - about declarations in single statement context
#22686 - similar error for interfaces and type aliases

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions