Skip to content

[Replacement]: auto-bind #1063

Closed
Closed

Description

@dreyfus92

Package to replace

auto-bind

Suggested replacement(s)

class fields with arrow functions (native)

Manifest type

native (replaceable by a built-in platform feature)

Rationale

auto-bind exists to bind class methods to their instance, which class fields with arrow functions now handle at the language level. both approaches allocate one function per instance, so there's no perf tradeoff.

Availability

class fields are ES2022

Code example (optional)

// before
import autoBind from 'auto-bind';

class Foo {
  constructor() {
    autoBind(this);
  }

  method() {
    return this.value;
  }
}

// after
class Foo {
  method = () => this.value;
}

// if prototype placement matters (spying, super calls, inherited methods):
class Foo {
  constructor() {
    this.method = this.method.bind(this);
  }

  method() {
    return this.value;
  }
}

Activity

  1. added
    accepted
    on Aug 29, 2026
  2. changed the title [-][Replacement]: auto-bind[/-] [+][Replacement]: `auto-bind`[/+] on Aug 29, 2026
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

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions