Skip to content

Modifier optional positional argument interferes with named argument #627

Closed Answered by chriskrycho
adc-mhaugen asked this question in Q&A
Discussion options

You must be logged in to vote

Optional positional arguments are not supported, because we model the combination of positional and named arguments as a list of arguments with the positional arguments first and then a named argument object at the end of the list. Given that, the actual type your signature represents is something more like this:

function translatedFoo(
  b: boolean,
  s?: string,
  options: { debounce?: number }
): void;

That signature is not legal TypeScript, though, as you can see in this playground. You end up with a different error message from Glint than the one in the playground because of the specific details of how we do the transformation and then supply the arguments to it in the template, but …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adc-mhaugen
Comment options

Answer selected by chriskrycho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #624 on October 04, 2023 14:58.