Skip to content

🐞 Update types to prevent @typescript-eslint/unbound-method errors #360

Open
@reify-tanner-stirrat

Description

@reify-tanner-stirrat

What happened?

const { activate } = useIdleTimer(config);

The above will throw:

@typescript-eslint/unbound-method: Avoid referencing unbound methods which may cause unintentional scoping of `this`. If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead.

According to this stackoverflow post, it's because there's a meaningful difference between:

type IIdleTimer = {
  activate(): bool;
}
// and
type IIdleTimer = {
  activate: () => bool;
}

which is that the former is typed as a function() definition and carries the this weirdness, where the latter is not.

Reproduction Steps

See above

Relevant log output

N/A

Screenshots or Additional Context

No response

Module Version

5.7.2

What browsers are you seeing the problem on? Select all that apply.

No response

What devices are you seeing the problem on?

No response

Verification

  • I have checked for existing closed issues and discussions.

Metadata

Metadata

Labels

bugA verified and reproducible bug.triageHas not been reviewed yet and should not be worked on.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions