Skip to content

--allowJs: Object.defineProperty on imported alias crashes compiler #35196

@Knagis

Description

@Knagis

TypeScript Version: 3.7.2, 3.8.0-dev-20191119, master

Search Terms: bindObjectDefinePrototypeProperty

Code

import A from "./a";

Object.defineProperty(A.prototype, "foo", {
    value: 0
});

Expected behavior:
Code transpiles without errors.

Actual behavior:

TypeError: Cannot set property 'symbol' of undefined
    at addDeclarationToSymbol (node_modules\typescript\lib\tsc.js:23649:25)
    at bindObjectDefinePrototypeProperty (node_modules\typescript\lib\tsc.js:25640:17)
    at bindWorker (node_modules\typescript\lib\tsc.js:25370:36)
    at bind (node_modules\typescript\lib\tsc.js:25179:13)
    at bindExpressionStatement (node_modules\typescript\lib\tsc.js:24503:13)
    at bindChildrenWorker (node_modules\typescript\lib\tsc.js:24010:21)
    at bindChildren (node_modules\typescript\lib\tsc.js:23931:17)
    at bind (node_modules\typescript\lib\tsc.js:25185:21)
    at node_modules\typescript\lib\tsc.js:23937:68
    at bindEach (node_modules\typescript\lib\tsc.js:23953:21)

Playground Link:
http://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=5&pc=4#code/JYWwDg9gTgLgBAQTgMyhEcBEA6A9AQ0wG4AoEgeQCMArAUwGMZsATW5YAO1oAU0xbYATwAUCbGDQwIMQfwA0WZBAiYFAbxJwtcAG74ANgFdaALjgAGEgF8AlESA

Related Issues:
#34647
#34493

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