Add Literal Suggestions to `ARIAMixin` and Fallback for Unknown Values

Open
#1,835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

Start by locating the ARIAMixin definitions and the generator inputs that determine each aria property type. Compare the existing string | null declarations with the requested known literal values and string & {} fallback, then find the relevant generated-output or type-generation tests. Done means known ARIA values are suggested while unknown strings remain accepted.

Written by the indexing model from the issue text.

Description

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: https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1184. While that issue suggested disallowing "unknown" values, my suggestion would still permit them but make the known options more discoverable in TypeScript.

Dominant language
TypeScript
Stars
740
Forks
474
Avg merge
2d 8h
Merged PRs (30d)
15

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript-DOM-lib-generator

All issues in microsoft/TypeScript-DOM-lib-generator

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.