mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
d74617cbd3
* refactor: types * feat: refactor types * chore: organize imports * fix: remaining references * docs: types * refactor: small changes * chore: changeset
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import './astro-jsx';
|
|
import type { OmitIndexSignature, Simplify } from './dist/type-utils.js';
|
|
import type { AstroBuiltinAttributes } from './dist/types/public/elements.js';
|
|
|
|
/** Any supported HTML or SVG element name, as defined by the HTML specification */
|
|
export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
|
|
|
|
/** The built-in attributes for any known HTML or SVG element name */
|
|
export type HTMLAttributes<Tag extends HTMLTag> = Omit<
|
|
astroHTML.JSX.DefinedIntrinsicElements[Tag],
|
|
keyof Omit<AstroBuiltinAttributes, 'class:list'>
|
|
>;
|
|
|
|
/**
|
|
* 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, 'as'> & {
|
|
as?: P['as'];
|
|
} & Omit<
|
|
// This is the same as HTMLAttributes<P['as']>, except we're using OmitIndexSignature to remove the index signature,
|
|
// used for data attribute, because it seems like it get too complex for TypeScript with it, not sure why.
|
|
OmitIndexSignature<astroHTML.JSX.DefinedIntrinsicElements[P['as']]>,
|
|
keyof Omit<AstroBuiltinAttributes, 'class:list'>
|
|
>;
|
|
|
|
export type Polymorphic<P extends { as: HTMLTag }> = PolymorphicAttributes<
|
|
Omit<P, 'as'> & { as: NonNullable<P['as']> }
|
|
>;
|
|
|
|
export type ComponentProps<T extends (args: any) => any> = Simplify<Parameters<T>[0]>;
|