Skip to content

Add Literal Suggestions to ARIAMixin and Fallback for Unknown Values #1835

Open
@DeepDoge

Description

@DeepDoge

The ARIAMixin currently uses string | null for each aria property type. The reason it’s just string rather than a union of valid values is to allow for future, yet unknown, valid values.

However, in TypeScript, we can prevent string from collapsing with literal unions by using string & {}. For instance, ariaCurrent could be typed as "page" | "step" | "location" | (string & {}) | null, suggesting valid options like "page", "step", and "location" while still allowing any other string as a fallback.

There is a related closed issue here: #1184. While that issue suggested disallowing "unknown" values, my suggestion would still permit them but make the known options more discoverable in TypeScript.

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