diff --git a/.changeset/khaki-ties-carry.md b/.changeset/khaki-ties-carry.md new file mode 100644 index 000000000000..42c4f71c1cc4 --- /dev/null +++ b/.changeset/khaki-ties-carry.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes Polymorphic type helper causing TypeScript errors in certain cases after the previous update diff --git a/packages/astro/types.d.ts b/packages/astro/types.d.ts index 3069f502b916..b04f062fdba8 100644 --- a/packages/astro/types.d.ts +++ b/packages/astro/types.d.ts @@ -1,13 +1,13 @@ import './astro-jsx'; import type { AstroBuiltinAttributes } from './dist/@types/astro.js'; -import type { Simplify } from './dist/type-utils.js'; +import type { OmitIndexSignature, Simplify } from './dist/type-utils.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 = Omit< - astroHTML.JSX.IntrinsicElements[Tag], + astroHTML.JSX.DefinedIntrinsicElements[Tag], keyof Omit >; @@ -18,7 +18,12 @@ export type CSSProperty = keyof astroHTML.JSX.KebabCSSDOMProperties; type PolymorphicAttributes

= Omit & { as?: P['as']; -} & HTMLAttributes; +} & Omit< + // This is the same as HTMLAttributes, 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, + keyof Omit + >; export type Polymorphic

= PolymorphicAttributes< Omit & { as: NonNullable }