This repository was archived by the owner on Mar 4, 2020. It is now read-only.
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Type checks on as
prop are not working properly #1527
Open
Description
Bug Report
Type checks on as
prop works only in basic case.
Primitive element
const a = <div type="button" />
// TS handles it 👍
// Error:(9, 12) TS2322: Type '{ type: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
// Property 'type' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Stardust element
<Image type="button" />
// Works in this case, when `as` prop is not specified 👍
// Error:(9, 12) TS2322: Type '{ type: string; }' is not assignable to type 'IntrinsicAttributes & Extended<ImageProps, DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>>'.
// Property 'type' does not exist on type 'IntrinsicAttributes & Extended<ImageProps, DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>>'.
Stardust element and broken cases
<Image as='div' type="button" />
// still not assignable, but passes type checks 💣
<Header description={{ as: 'div', type: 'button' }} />
// still not assignable, but passes type checks 💣
Version
latest