Skip to content

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

Closed

Description

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

Activity

  1. added a commit that references this issue on Nov 19, 2019
    9c0fab9
  2. Knagis commented on Nov 19, 2019

    @Knagis
    ContributorAuthor

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

  3. Knagis commented on Nov 19, 2019

    @Knagis
    ContributorAuthor

    Any chance this could also be added to 3.7.3?

  4. added a commit that references this issue on Nov 20, 2019
    17f5469
  5. added
    CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
    on Nov 20, 2019
  6. sandersn commented on Nov 20, 2019

    @sandersn
    Member

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

  7. added a commit that references this issue on Nov 20, 2019
    6a4a622
  8. added a commit that references this issue on Nov 20, 2019
    b9d5231
  9. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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