Skip to content

Modifier optional positional argument interferes with named argument #624

Closed

Description

@adc-mhaugen

Versions:
"@glint/core": "^1.2.0",
"environment": "ember-loose"

Code:

import Modifier from 'ember-modifier';

interface FooSignature {
    Element: HTMLElement;
    Args: {
        Positional: [boolean, string?];
        Named: { debounce?: number };
    };
}

export default class FooModifier extends Modifier<FooSignature> {
    modify(
        element: HTMLElement,
        [b, s]: [boolean, string?],
        { debounce }: { debounce?: number }
    ) {
        console.log('foo', element, b, s, debounce);
    }
}

declare module '@glint/environment-ember-loose/registry' {
    export default interface Registry {
        foo: typeof FooModifier;
    }
}

When I try to use the modifier without the optional second positional argument I get this error:

Argument of type '{ [NamedArgs]: true; debounce: number; }' is not assignable to parameter of type 'string'.glint(2345)

Screenshot 2023-09-30 at 9 35 47 AM

Are optional positional arguments not supported or am I doing something else wrong?

thanks!

Activity

  1. locked and limited conversation to collaborators on Oct 4, 2023
  2. converted this issue into a discussion #627 on Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions