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 type (MIME) attribute types #3305

Merged
merged 2 commits into from
Aug 26, 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
19 changes: 13 additions & 6 deletions src/jsx/intrinsic-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export namespace JSX {
interface EmbedHTMLAttributes extends HTMLAttributes {
height?: number | string | undefined
src?: string | undefined
type?: string | undefined
type?: StringLiteralUnion<BaseMime> | undefined
width?: number | string | undefined
}

Expand Down Expand Up @@ -495,7 +495,7 @@ export namespace JSX {
imagesizes?: string | undefined
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined
sizes?: string | undefined
type?: string | undefined
type?: StringLiteralUnion<BaseMime> | undefined
charSet?: string | undefined

// React 19 compatibility
Expand Down Expand Up @@ -607,7 +607,7 @@ export namespace JSX {
form?: string | undefined
height?: number | string | undefined
name?: string | undefined
type?: string | undefined
type?: StringLiteralUnion<BaseMime> | undefined
usemap?: string | undefined
width?: number | string | undefined
}
Expand Down Expand Up @@ -658,7 +658,10 @@ export namespace JSX {
nomodule?: boolean | undefined
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined
src?: string | undefined
type?: string | undefined
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type
*/
type?: StringLiteralUnion<'' | 'text/javascript' | 'importmap' | 'module'> | undefined

// React 19 compatibility
crossOrigin?: CrossOrigin
Expand All @@ -681,20 +684,24 @@ export namespace JSX {
value?: string | ReadonlyArray<string> | number | undefined
}

type MediaMime = BaseMime & (`image/${string}` | `audio/${string}` | `video/${string}`)
interface SourceHTMLAttributes extends HTMLAttributes {
height?: number | string | undefined
media?: string | undefined
sizes?: string | undefined
src?: string | undefined
srcset?: string | undefined
type?: string | undefined
type?: StringLiteralUnion<MediaMime> | undefined
width?: number | string | undefined
}

interface StyleHTMLAttributes extends HTMLAttributes {
media?: string | undefined
scoped?: boolean | undefined
type?: string | undefined
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#type
*/
type?: '' | 'text/css' | undefined

// React 19 compatibility
href?: string | undefined
Expand Down