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

Breaks "this" in class expressions #85

Open
wh1t3cAt1k opened this issue Sep 2, 2022 · 0 comments
Open

Breaks "this" in class expressions #85

wh1t3cAt1k opened this issue Sep 2, 2022 · 0 comments

Comments

@wh1t3cAt1k
Copy link

wh1t3cAt1k commented Sep 2, 2022

Excerpt from babel-jest.config.js:

    plugins: [
        '@userlike/babel-plugin-joke',
        [
            'module-resolver',
            {
                root: [repositoryRoot],
                alias: {
                        /**/
                },
                cwd: repositoryRoot,
            },
        ],
        ['@babel/plugin-proposal-decorators', { legacy: true }],
        '@babel/plugin-proposal-class-properties',
        ['babel-plugin-transform-async-to-promises', { inlineHelpers: true }],
        'babel-plugin-macros',
    ],
    presets: [
        '@babel/preset-typescript',
        '@babel/preset-react',
        ['@babel/preset-env', { targets: { node: 16 } }],
    ],

Simplified source file file: test.ts

it('is a simplified test', async () => {
    customFunctionMap[identifier] = coercePartial<
        ClassType<FunctionCallBase> & VelixoFunctionStatic
    >(
        class {
            public constructor(private readonly _group: string) {}

            public static readonly shouldClusterComputations = true;

            public getInvocationClusterKey = (): string => this._group; // here!
        }
    );

    const result = new classVariable("group");

Resulting file:

it('...', _async(function () {
  var _class;

  _customFunctionMap.customFunctionMap[identifier] = (0, _coercePartial.coercePartial)((_class = class {
    constructor(_group) {
      this._group = _group;

      this.getInvocationClusterKey = () => _this._group; // note "_this" is renamed unnecessarily here
    }

  }, _class.shouldClusterComputations = true, _class));

I verified that it does not happen when I remove the plugin from the plugins list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant