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

LionSelectInvoker improper typing? #2095

Open
nbamfordcirium opened this issue Oct 16, 2023 · 0 comments
Open

LionSelectInvoker improper typing? #2095

nbamfordcirium opened this issue Oct 16, 2023 · 0 comments

Comments

@nbamfordcirium
Copy link

Expected behavior

I have overriden the LionSelectInvoker getSlots method with the following definition for the after function:

export class MySelectInvoker extends LionSelectInvoker {
  get slots() {
    return {
      ...super.slots,
      after: () => {
        return html`
          <span style="display: flex; align-items: trailing;">
            ${this.htmlClearButton} ${this.htmlSuccessIcon}
            ${MySelectInvoker.htmlDropdownIcon}
          </span>
        `;
      },
    };
  }
}

This works fine in the select and I did not expect to get any typescript errors.

Actual Behavior

I get the typescript error: Property 'slots' in type 'EvSelectInvoker' is not assignable to the same property in base type 'LionSelectInvoker'. Type '{ after: () => TemplateResult<1>; }' is not assignable to type '{ after: () => HTMLSpanElement; }'.

Which makes sense, because LionSelectInvoker.d.ts has the type defined as:

get slots(): {
  after: () => HTMLSpanElement;
};

I've worked around the issue by casting the return as unknown as HTMLSpanElement, but I feel uneasy shortcircuiting lion types like this. Am I okay returning the templateresult like I have (which seems to work fine in the browser)? Or is the type in LionSelectInvoker.d.ts simply too restrictive?

Additional context

LionSelectRich, @lion/ui@0.4.1

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

No branches or pull requests

1 participant