Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Static fat functions don't keep context #1464

@maccman

Description

@maccman

Say I have a static function that uses fat arrows (to keep context):

class Test
  @foo: => "ga"

The following code is produced:

var Test;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Test = (function() {
  function Test() {
    this.Test = __bind(this.Test, this);
  }
  Test.foo = function() {
    return "ga";
  };
  return Test;
})();

When instead this should be produced:

var Test;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Test = (function() {
  function Test() {}
  Test.foo = __bind(function() {
    return "ga";
  }, Test);
  return Test;
})();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions