Skip to content

Crash when opening globalThis as a namespace #33860

Closed
@shicks

Description

@shicks

TypeScript Version: v3.7.0-dev.20191006

Search Terms: globalThis namespace crash

Code

namespace globalThis {
    export function foo() { console.log('x'); }
}

Expected behavior:
Should either compile or give an error

Actual behavior:
Crash:

/tmp/xx/node_modules/typescript/lib/tsc.js:78471
                throw e;
                ^
TypeError: Cannot read property 'length' of undefined
    at checkModuleDeclaration (/tmp/xx/node_modules/typescript/lib/tsc.js:52018:44)
    at checkSourceElementWorker (/tmp/xx/node_modules/typescript/lib/tsc.js:52563:28)
    at checkSourceElement (/tmp/xx/node_modules/typescript/lib/tsc.js:52408:17)
    at Object.forEach (/tmp/xx/node_modules/typescript/lib/tsc.js:225:30)
    at checkSourceFileWorker (/tmp/xx/node_modules/typescript/lib/tsc.js:52702:20)
    at checkSourceFile (/tmp/xx/node_modules/typescript/lib/tsc.js:52676:13)
    at getDiagnosticsWorker (/tmp/xx/node_modules/typescript/lib/tsc.js:52743:17)
    at Object.getDiagnostics (/tmp/xx/node_modules/typescript/lib/tsc.js:52732:24)
    at /tmp/xx/node_modules/typescript/lib/tsc.js:78489:85
    at runWithCancellationToken (/tmp/xx/node_modules/typescript/lib/tsc.js:78464:24)

Playground Link:
http://www.typescriptlang.org/play/index.html?ts=3.7-Beta&ssl=3&ssc=2&pln=1&pc=1#code/HYQwtgpgzgDiDGEAEBzANgewEYjQFQAsBLKJAbwCglqkIAPGDAJwBckAzAV2HhaI2AcMGABQBKckngCoGNBAB0mFCIDkdVWIDcSAL4VdQA

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions