Skip to content
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
layershifter opened this issue Jun 21, 2019 · 0 comments · May be fixed by #2372
Open

Type checks on as prop are not working properly #1527

layershifter opened this issue Jun 21, 2019 · 0 comments · May be fixed by #2372
Labels
vsts Paired with ticket in vsts

Comments

@layershifter
Copy link
Member

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

@layershifter layershifter changed the title Type checks on as prop are not working Type checks on as prop are not working properly Jun 21, 2019
@pkumarie2011 pkumarie2011 added the vsts Paired with ticket in vsts label Jun 21, 2019
@layershifter layershifter linked a pull request Feb 22, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
vsts Paired with ticket in vsts
Projects
None yet
2 participants