Skip to content

--allowJs (3.7.0 regression): Cannot reference this when extending imported function prototype #34647

@Knagis

Description

@Knagis

TypeScript Version: 3.7.x-dev.20191021

Search Terms:

  • Cannot set property 'symbol' of undefined

Code
Originally encountered when transpiling BabylonJS ES6 code (@babylonjs/core/Animations/animatable.js)

Minimum repro:

import { A } from "./a";

A.prototype.foo = function () {
    this.bar = 0;
};

Expected behavior:
Code is transpiled.

Actual behavior:

node_modules\typescript\lib\tsc.js:23641
            node.symbol = symbol;
                        ^

TypeError: Cannot set property 'symbol' of undefined
    at addDeclarationToSymbol (node_modules\typescript\lib\tsc.js:23641:25)
    at bindThisPropertyAssignment (node_modules\typescript\lib\tsc.js:25564:25)
    at bindWorker (node_modules\typescript\lib\tsc.js:25270:29)
    at bind (node_modules\typescript\lib\tsc.js:25165:13)
    at bindExpressionStatement (node_modules\typescript\lib\tsc.js:24496:13)
    at bindChildrenWorker (node_modules\typescript\lib\tsc.js:24002:21)
    at bindChildren (node_modules\typescript\lib\tsc.js:23923:17)
    at bind (node_modules\typescript\lib\tsc.js:25171:21)
    at node_modules\typescript\lib\tsc.js:23929:68
    at bindEach (node_modules\typescript\lib\tsc.js:23945:21)
error Command failed with exit code 1.

Playground Link:

http://www.typescriptlang.org/play/?ts=3.7-Beta&ssl=3&ssc=2&pln=1&pc=1#code/JYWwDg9gTgLgBAbzgQTgXzgMyhEcBEAdAPQCG+A3AFBXKFg4wQwCeYApoZhBHALxYArgDsAxjGARhcABQBKRFTjK4MABbAAzoQBGpKPzgAGamgpA (see errors in browser console)

Related Issues:

#34493

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions