Repository navigation
Don't emit named-arg values in bindInvokable, so generic helpers can't collapse curried types - #1249
Merged
NullVoxPopuli merged 3 commits intoSep 23, 2026
Conversation
A curried keyword with named args emits a comma pair (typed-ember#1068): the keyword call validates the args, and `bindInvokable(...)` produces the curried value. When a named arg's value was a call to a generic function that returns a function, like ember-set-helper's `(set this "el")`, TypeScript skipped it during `bindInvokable`'s first inference pass (`SkipGenericFunctions`). Together with the likewise-skipped `resolveForBind(...)`, that lost all of `bindInvokable`'s type parameters and collapsed the result to `Invokable<(...args: unknown[]) => unknown>`. Yielded against `WithBoundArgs`, `Args` was then inferred from the expected type and valid code was rejected. `bindInvokable` only reads the named args' keys, so the transform now emits `boundArg` for every value there. This generalizes the typed-ember#1147 fix, which covered only `fn`, so the `bindPositional` special case is removed and `fn` always emits a plain call (typed-ember#1247). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
NullVoxPopuli
approved these changes
Sep 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A generic helper that returns a function, used as a named arg of
{{component}}/{{helper}}/{{modifier}}, breaks the curried value's type. ember-set-helper's(set this "el")is the common case:{{#let}}doesn't error. That's only because its type has collapsed toInvokable<(...args: unknown[]) => unknown>, which accepts anything.onCreate=this.onCreate(not generic) works.@glint/ember-tsc1.0.7 /@glint/template1.7.2. It fails on 1.11.x / template 1.9.0.Root cause
Since #1078 (fix for #1068, released in
@glint/ember-tsc1.2.3 /@glint/template1.7.7), a curried keyword with named args emits a comma pair:During its first inference pass, TypeScript skips any argument that is a call to a generic function returning a function (
SkipGenericFunctions).setter(...)is such a call, and so isresolveForBind(...). With both skipped,bindInvokableinfers none of its type parameters, and the result collapses toInvokable<(...args: unknown[]) => unknown>. When the value is yielded againstWithBoundArgs,Argsgets inferred from the expected type instead, and the modifier fails against it.This is the mechanism behind #1147. The fix there only covered
fn, by swapping it for the non-genericbindPositionalinsidebindInvokable. Any other helper with this shape still broke it.It isn't caused by ember-set-helper's loose
(value?: unknown) => T[K]return type. Before this change, all of these fail the same way:(value: T[K]) => void/() => void)(value: T[K]) => void<T>(x: T) => (e: HTMLElement) => voidstring)Fix
bindInvokableonly reads the keys of its named args (keyof GivenNamed). The keyword call in the other half already validates the values, with the invokable's arg types as context. So thebindInvokablehalf now emits a placeholder for each value:As a result,
fn'sbindPositionalspecial case can't be reached anymore, so it's removed.fnnow always emits a plain call, which keeps the #1247 contextual typing.Tests
test-packages/ts-gts-7-1-app/src/bind-generic-helper-arg.test.gtscovers:(modifier), and the same through(component){{#let}}case, which now asserts the curried value keeps its type(component)helper when pre-binding optional union arguments #1144, Issues withfnhelper in combination withcomponenthelper #1147 and{{fn}}with a generic callback no longer infers from the arg's type (regression from #1189) #1247 regression tests still pass.🤖 Generated with Claude Code