DefinitelyTyped / DefinitelyTyped/DefinitelyTyped
[react] Add commandFor and command attributes to ButtonHTMLAttributes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 51.4k
- Forks
- 30.4k
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 108
Description
Summary
The Invoker Commands API adds commandfor and command attributes to <button>. These are missing from ButtonHTMLAttributes in @types/react.
HTML spec
- whatwg/html PR: https://github.com/whatwg/html/pull/9841
- MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/commandForElement
Browser support
- Chrome/Edge 135+
- Safari Technology Preview
- Firefox Nightly (behind flag)
Expected types
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
commandFor?: string | undefined
command?: string | undefined
}
command accepts built-in values (toggle-popover, show-popover, hide-popover, show-modal, close, request-close) and custom strings (prefixed with --).
Current workaround
Projects augment the module locally:
import 'react'
declare module 'react' {
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
commandFor?: string
command?: string
}
}
React already ships popoverTarget and popoverTargetAction on button — commandFor/command is the successor API from the same spec space.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ButtonHTMLAttributes in @types/react and compare its existing popover-related attributes with the HTML spec and MDN links. Add the two optional string attributes shown in Expected types, then verify that TypeScript consumers no longer need the module augmentation workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100