Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta issue: function helper resolution bugs #396

Closed
dfreeman opened this issue Aug 29, 2022 · 4 comments · Fixed by #470
Closed

Meta issue: function helper resolution bugs #396

dfreeman opened this issue Aug 29, 2022 · 4 comments · Fixed by #470
Labels
bug Something isn't working

Comments

@dfreeman
Copy link
Member

I'm opening this to track issues with function helpers that we expect will be fixed with our planned overhaul of the internal representation of invokable template entities within Glint.

@dfreeman dfreeman added the bug Something isn't working label Aug 29, 2022
@dfreeman
Copy link
Member Author

dfreeman commented Aug 29, 2022

unknown is treated as named-args-like

Given this function:

declare function isEqual(a: unknown, b: unknown): boolean;

This will resolve as a helper with one positional arg and shapeless named args.

@dfreeman
Copy link
Member Author

Named-args-like args have to be passed as named args

Given this function:

declare function constructLanguageTag(options: { country: string; language: string }): string;

This should be legal to invoke as either of the following:

{{constructLanguageTag country="US" language="en"}}
{{constructLanguageTag (hash country="US" language="en")}}

However, currently only the former is accepted.

@boris-petrov
Copy link
Contributor

Class args don't work in any way

Given:

class Foo {}
const someFooInstance: Foo;
declare function handleFoo(foo: Foo): string;

This should be legal:

{{handleFoo someFooInstance}}

However, currently there is an error - Expected 0 arguments, but got 1.

@dfreeman
Copy link
Member Author

Not a helper resolution bug, but something we should verify as part of overhauling [Invoke]: we should make sure assignability works as expected with ComponentLike, WithBoundArgs, etc.

As a concrete example, this component:

class MyComponent extends Component<{
  Args: { foo?: string };
  Element: HTMLImageElement;
  Blocks: { default: [] };
}> {}

Should be assignable to (among other things) ComponentLike with no parameters, since it's legal to invoke with no args, ...attributes or blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants