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

fix(types): Fixes HTMLAttribute extend to allow everything #10561

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- "scripts/smoke/check.js"
- "packages/astro/src/@types/astro.ts"
- "pnpm-lock.yaml"
- "packages/astro/types.d.ts"

env:
ASTRO_TELEMETRY_DISABLED: true
Expand Down
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
9 changes: 4 additions & 5 deletions packages/astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +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'>
> & {
[key: string]: string | number | boolean | null | undefined;
};
>;

/**
* 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
Loading