You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionSomeComponent<Textends'button'|'a'>(props: {element?: T}&JSX.IntrinsicElements[T]): JSX.Element{// Just so the return value is RectElement, the rendered element doesnt matterreturn<div/>}functionTest<Textends'button'|'a'>(el: T){// ✅// return <SomeComponent element={el} className='yolo' />// ✅// return <SomeComponent element={el}>{null}</SomeComponent>// ❌ Type '{ element: T; }' is not assignable to type 'IntrinsicElements[T]'.// TS here completely ignores the props type "{ element?: T } & JSX.IntrinsicElements[T]" where I specify the element key?return<SomeComponentelement={el}/>}
🙁 Actual behavior
I am getting Type '{ element: T; }' is not assignable to type 'IntrinsicElements[T]'. error even-though my type is specified as intersection of { element?: T } & JSX.IntrinsicElements[T]. I have checked and there is no element key in the IntrinsicElements - I can prove that by using Omit<JSX.IntrinsicElements[T], 'element'>, which still returns error. Also when extracting the type into a separate type like this
typeTEST={element?: 'button'|'a'}&JSX.IntrinsicElements['button'|'a']typeTEST_ELEMENT=TEST['element']// ✅ ^^ "button" | "a" | undefined
it returns the expected type of element
🙂 Expected behavior
I expect there is no error and that Type '{ element: T; }' is ASSIGNABLE to type '{ element: T; } & IntrinsicElements[T]'..
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
intersection, merge types, react intrinsic type
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
I am getting
Type '{ element: T; }' is not assignable to type 'IntrinsicElements[T]'.
error even-though my type is specified as intersection of{ element?: T } & JSX.IntrinsicElements[T]
. I have checked and there is no element key in the IntrinsicElements - I can prove that by using Omit<JSX.IntrinsicElements[T], 'element'>, which still returns error. Also when extracting the type into a separate type like thisit returns the expected type of
element
🙂 Expected behavior
I expect there is no error and that
Type '{ element: T; }' is ASSIGNABLE to type '{ element: T; } & IntrinsicElements[T]'.
.The text was updated successfully, but these errors were encountered: