Skip to content

Typesafety on useOverlay props #3915

Open
@schillerenrico

Description

@schillerenrico

Description

Currently when I use useOverlay and pass props it says props is type any.
by adding satisfies InstanceType<typeof COMPONENT>["$props"] it gets the right types.

But it should work out of the box. Could the typesafety for props be implemented?

current solution

          useOverlay()
            .create(COMPONENT, {
              props: {
                id: id,
                onUpdated() {
...
                },
              } satisfies InstanceType<typeof COMPONENT>["$props"],
            })
            .open();

Additional context

Something like this could create type safety

function createTypedOverlay<T extends new (...args: any) => any>(
  component: T,
  options: {
    props: InstanceType<T>["$props"];
    [key: string]: any;
  }
) {
  return useOverlay().create(component, options);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions