Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Knagis opened this issue Nov 19, 2019 · 3 comments · Fixed by #35198
Closed

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

Knagis opened this issue Nov 19, 2019 · 3 comments · Fixed by #35198
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Comments

@Knagis
Copy link
Contributor

Knagis commented Nov 19, 2019

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

@Knagis
Copy link
Contributor Author

Knagis commented Nov 19, 2019

@sandersn - pinging you since you handled the related issues. The linked PR follows the same approach as the previous two.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Nov 19, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.8.0 milestone Nov 19, 2019
@Knagis
Copy link
Contributor Author

Knagis commented Nov 19, 2019

Any chance this could also be added to 3.7.3?

@sandersn sandersn added the Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output label Nov 20, 2019
@sandersn
Copy link
Member

It's a simple fix for a crash, so I think it's a good fit for 3.7.3.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this issue Nov 20, 2019
Component commits:
9c0fab9 Fix crash with Object.defineProperty for imported alias (--allowJs)
Fixes microsoft#35196
sandersn pushed a commit that referenced this issue Nov 20, 2019
Component commits:
9c0fab9 Fix crash with Object.defineProperty for imported alias (--allowJs)
Fixes #35196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants