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
When using composing a component that uses any of the *HTMLAttributes interfaces from React, TypeScript no longer infers the types of arguments to event handlers.
Weirdly, it infers correctly if you use the plain HTMLAttributes interface… but only if some other prop is causing an error 🥴
To Reproduce
Reduced test case:
import{InputHTMLAttributes}from"react";import{createCss}from"@stitches/react";const{ styled }=createCss({});typeInputProps=InputHTMLAttributes<HTMLInputElement>;functionInput(props: InputProps){return<input{...props}/>;}constStyledInput=styled(Input,{});exportdefaultfunctionApp(){// Parameter 'e' implicitly has an 'any' type. ts(7006)return<StyledInputonChange={(e)=>console.log(e)}/>;}
Bug report
Describe the bug
When using composing a component that uses any of the
*HTMLAttributes
interfaces from React, TypeScript no longer infers the types of arguments to event handlers.Weirdly, it infers correctly if you use the plain
HTMLAttributes
interface… but only if some other prop is causing an error 🥴To Reproduce
Reduced test case:
Here's a sandbox with a more comprehensive example: https://codesandbox.io/s/dreamy-oskar-chq4z?file=/src/App.tsx
Expected behavior
TypeScript should infer the correct type for the event handler arguments.
The text was updated successfully, but these errors were encountered: