X Tutup
Skip to content

Losing context when calling method with a computed key #266

@ark120202

Description

@ark120202

Playground

Suggested solution:

-- Simple cases
foo["bar"](foo);
foo["bar"](foo, 1);

When object isn't a pure value:

c.chain()['foo']('bar');
__TS__ComputedCall(c:chain(), "foo", "bar");

Chained api:

Promise.resolve(1)
  ['then'](() => Promise.resolve(2))
  ['then'](() => Promise.reject(3))
  ['catch'](() => Promise.resolve(4))
  ['then'](console.log);
__TS__ComputedCall(
  __TS__ComputedCall(
    __TS__ComputedCall(
      Promise:resolve(1), "then", function() return Promise:resolve(2) end
    ), "then", function() return Promise:reject(3) end
  ), "catch", function() return Promise:resolve(4) end
), "then", console.log);

This implementation may be found there: https://github.com/ark120202/babel-lua/tree/master/packages/babel-plugin-lua-function-context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup