Skip to content

tsc crashes resolving a type of computed property in destructiring assignment #26321

Description

TypeScript Version: 3.1.0-dev.20180809, 3.0.1

Search Terms:
Cannot read property 'charCodeAt' of undefined

Code

interfaceLimit1{propName: {min: number;max: number};}interfaceLimit2{propName: {min: number;max: number};}typeLimit=Limit1|Limit2;// should be Union typeexportinterfaceMeta{propName: "propName";}functionfoo(meta: Meta,limits: Limit): void{const{[`propName`]: {min: minBonus,max: maxBonus},// should be computed}=limits;}

Expected behavior:
No crash, code compiled

Actual behavior:

Cannot read property 'charCodeAt' of undefined
.../node_modules/typescript/lib/tsc.js:68035
throw e;
^

TypeError: Cannot read property 'charCodeAt' of undefined
at isLateBoundName (.../node_modules/typescript/lib/tsc.js:28756:25)
at createUnionOrIntersectionProperty (.../node_modules/typescript/lib/tsc.js:29638:38)
at getUnionOrIntersectionProperty (.../node_modules/typescript/lib/tsc.js:29699:28)
at getPropertyOfUnionOrIntersectionType (.../node_modules/typescript/lib/tsc.js:29707:28)
at getPropertyOfType (.../node_modules/typescript/lib/tsc.js:29727:24)
at checkVariableLikeDeclaration (.../node_modules/typescript/lib/tsc.js:43025:36)
at checkBindingElement (.../node_modules/typescript/lib/tsc.js:43123:20)
at checkSourceElement (.../node_modules/typescript/lib/tsc.js:44827:28)
at Object.forEach (.../node_modules/typescript/lib/tsc.js:168:30)
at checkVariableLikeDeclaration (.../node_modules/typescript/lib/tsc.js:43036:20)

Playground Link:

Note, that the code is not compiled

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions