Skip to content

Generics not supported when using bound functions #1303

Open
@JohnMarsden24

Description

@JohnMarsden24

Describe the feature you'd like:

Happy to give this a try myself!

I've found myself repeating the same pattern of typecasting elements returned from queries when using render when I need to access specific element properties as the return type for queries is always HTMLElement as seen in the two below screenshots:

Screenshot 2024-04-21 at 19 10 59 Screenshot 2024-04-21 at 19 12 54

Suggested implementation:

Firstly I thought about using function overloads and literal types to fix this problem but then realised any HTML element can be assigned a role so I then thought about using generics and came across this old issue which was implemented several years ago. In that thread it said the generics got lost when using screen, which was addressed and fixed but it looks like the same problem applies to render.

I imagine the fix will be similar to that found when adding generics to screen queries

Describe alternatives you've considered:

Open to suggestions

Teachability, Documentation, Adoption, Migration Strategy:

Allow users to pass generics to queries returned from render:

Screenshot 2024-04-21 at 21 34 23

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