Skip to content

Declare Link's actions as arrow functions - #1069

Closed
johanrd wants to merge 1 commit into
buschtoens:mainfrom
johanrd:arrow-link-actions
Closed

johanrd wants to merge 1 commit into
buschtoens:mainfrom
johanrd:arrow-link-actions

Conversation

@johanrd

@johanrd johanrd commented Sep 23, 2026

Copy link
Copy Markdown

transitionTo, replaceWith and open are bound by @action, but their types say "method". So typescript-eslint's unbound-method reports {{on "click" link.open}} when type-aware rules run on templates (emberjs/rfcs#1045 comment). As arrow functions, the types say they are bound.

Possibly breaking at runtime: Link is exported as a class. A subclass outside this repo that overrides one of these as a method would now be ignored, because the arrow field on the instance shadows the prototype method. TestLink overrides them with arrow fields too, so it still works.

TestLink's overrides now take event?: Event | unknown, like Link's: property types are checked strictly, so the narrower Event no longer fits. It prevents the default with the existing preventDefault helper.

Types, tests (46) and build pass. lint:js reports the same 6 errors in tests/unit/test-helpers/link-for-test.ts as main.

Cowritten by Claude

@action binds transitionTo, replaceWith and open, but their types say
method, so typescript-eslint's unbound-method reports
{{on "click" link.open}}. TestLink's overrides take the same event type
as Link's, which property types require.
@johanrd

johanrd commented Sep 23, 2026

Copy link
Copy Markdown
Author

closing, needs some refac first i think

@johanrd johanrd closed this Sep 23, 2026
@gossi

gossi commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Happy to accept it though :) Also hit me up on discord to move such thing forward.

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

Successfully merging this pull request may close these issues.

2 participants