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

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

Open
DeepDoge opened this issue Nov 2, 2024 · 1 comment
Open

Comments

@DeepDoge
Copy link

DeepDoge commented Nov 2, 2024

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.

@saschanaz
Copy link
Contributor

Similar suggestion with string & {} happened somewhere else, but I think in 2024 the situation is different, we already have several hardcoded enums. PR welcome.

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

2 participants