Skip to content

Commit

Permalink
nit: do it some other way
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Mar 26, 2024
1 parent aa96dcf commit cab0bff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 7 additions & 1 deletion packages/astro/astro-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ declare namespace astroHTML.JSX {
| 'search'
| 'send'
| undefined
| null;
| null;
exportparts?: string | undefined | null;
hidden?: boolean | string | undefined | null;
id?: string | undefined | null;
Expand Down Expand Up @@ -584,6 +584,9 @@ declare namespace astroHTML.JSX {
results?: number | string | undefined | null;
security?: string | undefined | null;
unselectable?: 'on' | 'off' | undefined | null; // Internet Explorer

// Allow data- attribute
[key: `data-${string}`]: any;
}

type HTMLAttributeReferrerPolicy =
Expand Down Expand Up @@ -1344,6 +1347,9 @@ declare namespace astroHTML.JSX {
yChannelSelector?: string | undefined | null;
z?: number | string | undefined | null;
zoomAndPan?: string | undefined | null;

// Allow data- attribute
[key: `data-${string}`]: any;
}

interface DefinedIntrinsicElements {
Expand Down
10 changes: 4 additions & 6 deletions packages/astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
export type HTMLAttributes<Tag extends HTMLTag> = Omit<
astroHTML.JSX.IntrinsicElements[Tag],
keyof Omit<AstroBuiltinAttributes, 'class:list'>
> & {
// This is not needed in the actual JSX definitions, because TypeScript implicitly adds it in JSX, however we need it here in case someone is using HTMLAttributes directly
[key: `${string}-${string}`]: any;
};
>;

/**
* All the CSS properties available, as defined by the CSS specification
*/
export type CSSProperty = keyof astroHTML.JSX.KebabCSSDOMProperties;

type PolymorphicAttributes<P extends { as: HTMLTag }> = Omit<P & HTMLAttributes<P['as']>, 'as'> & {
type PolymorphicAttributes<P extends { as: HTMLTag }> = Omit<P, 'as'> & {
as?: P['as'];
};
} & HTMLAttributes<P['as']>;

export type Polymorphic<P extends { as: HTMLTag }> = PolymorphicAttributes<
Omit<P, 'as'> & { as: NonNullable<P['as']> }
>;
Expand Down

0 comments on commit cab0bff

Please sign in to comment.