You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Similar suggestion with string & {} happened somewhere else, but I think in 2024 the situation is different, we already have several hardcoded enums. PR welcome.
The
ARIAMixin
currently usesstring | null
for each aria property type. The reason it’s juststring
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 usingstring & {}
. 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.
The text was updated successfully, but these errors were encountered: