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

feat(jsx): improve form attribute types #3330

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/jsx/intrinsic-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export namespace JSX {
interface ButtonHTMLAttributes extends HTMLAttributes {
disabled?: boolean | undefined
form?: string | undefined
formenctype?: string | undefined
formmethod?: string | undefined
formenctype?: HTMLAttributeFormEnctype | undefined
formmethod?: HTMLAttributeFormMethod | undefined
formnovalidate?: boolean | undefined
formtarget?: HTMLAttributeAnchorTarget | undefined
name?: string | undefined
Expand Down Expand Up @@ -303,11 +303,21 @@ export namespace JSX {
name?: string | undefined
}

/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#method */
type HTMLAttributeFormMethod = 'get' | 'post' | 'dialog'
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#enctype */
type HTMLAttributeFormEnctype =
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
| 'text/plain'
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#autocomplete */
type HTMLAttributeFormAutocomplete = 'on' | 'off'

interface FormHTMLAttributes extends HTMLAttributes {
'accept-charset'?: string | undefined
autocomplete?: string | undefined
enctype?: string | undefined
method?: string | undefined
'accept-charset'?: StringLiteralUnion<'utf-8'> | undefined
autocomplete?: HTMLAttributeFormAutocomplete | undefined
enctype?: HTMLAttributeFormEnctype | undefined
method?: HTMLAttributeFormMethod | undefined
name?: string | undefined
novalidate?: boolean | undefined
target?: HTMLAttributeAnchorTarget | undefined
Expand Down Expand Up @@ -446,8 +456,8 @@ export namespace JSX {
checked?: boolean | undefined
disabled?: boolean | undefined
form?: string | undefined
formenctype?: string | undefined
formmethod?: string | undefined
formenctype?: HTMLAttributeFormEnctype | undefined
formmethod?: HTMLAttributeFormMethod | undefined
formnovalidate?: boolean | undefined
formtarget?: HTMLAttributeAnchorTarget | undefined
height?: number | string | undefined
Expand Down