Skip to content

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

Closed

Description

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

Activity

  1. Knagis commented on Oct 22, 2019

    @Knagis
    ContributorAuthor

    Nathan Shively-Sanders (@sandersn) - you seem to be the person looking into the similar issues.

  2. Knagis commented on Oct 22, 2019

    @Knagis
    ContributorAuthor

    Created a PR #34650 with a fix that follows the same approach as #34566.

  3. 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

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