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
{{ message }}
Repository navigation
Incorrectly merging JSX.IntrinsicElements with other properties / JSX issue? #50177
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]'..
Activity