Skip to content

tsc crashes with TypeError: Cannot read property 'text' of undefined #32358

@hazolsky

Description

@hazolsky

TypeScript Version: 3.6.0-dev.20190711 (also checked on stable 3.5.2)

Search Terms:

  • TypeError: Cannot read property 'text' of undefined at emitPropertyAccessExpression

Code

test.ts:

const fn = (param: string) => undefined;

const foo = {bar: 'a'};
fn(({[foo.bar]: c}) => undefined);
$ tsc test.ts

Expected behavior:
tsc exits with error TS2345: Argument of type '({[foo.bar]: c}: any) => void' is not assignable to parameter of type 'string'. on line 4.

Actual behavior:
tsc crashes with error:

node_modules/typescript/lib/tsc.js:74862
                throw e;
                ^

TypeError: Cannot read property 'text' of undefined
    at emitPropertyAccessExpression (node_modules/typescript/lib/tsc.js:71027:77)
    at pipelineEmitWithHint (node_modules/typescript/lib/tsc.js:70478:32)
    at emitExpression (node_modules/typescript/lib/tsc.js:70140:13)
    at emitComputedPropertyName (node_modules/typescript/lib/tsc.js:70684:13)
    at pipelineEmitWithHint (node_modules/typescript/lib/tsc.js:70207:32)
    at emit (node_modules/typescript/lib/tsc.js:70127:13)
    at emitBindingElement (node_modules/typescript/lib/tsc.js:70999:17)
    at pipelineEmitWithHint (node_modules/typescript/lib/tsc.js:70297:32)
    at emit (node_modules/typescript/lib/tsc.js:70127:13)
    at emitNodeList (node_modules/typescript/lib/tsc.js:72467:21)

Playground Link:

http://www.typescriptlang.org/play/#code/MYewdgzgLgBAZmGBeGAKADgQwE6YLYBcM02AlmAOYCUyAfDAK5gAmApnOa8wNwBQvoSLDggQyGAG8ARjiIByTHIC+fBKlQSA2iJAA6GdgC6RYEppJ6TNhzBcqfIA

Related Issues:
Not found.

Original issue: palantir/tslint#4791

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions