Open
Description
Expected behavior
Typescript will compile without errors.
Current behavior
Ref types mismatch.
TS2322: Type '(instance: ReactInstance) => void' is not assignable to type 'string | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined'. Type '(instance: ReactInstance) => void' is not assignable to type '(instance: HTMLDivElement | null) => void'. Types of parameters 'instance' and 'instance' are incompatible. Type 'HTMLDivElement | null' is not assignable to type 'ReactInstance'. Type 'null' is not assignable to type 'ReactInstance'. index.d.ts(143, 9): The expected type comes from property 'ref' which is declared here on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'
Steps to reproduce
function MyComponent() {
const renderList: React.ComponentProps<typeof List>['itemsRenderer'] = (items, ref) => (
<div className={classes.root} ref={ref}>
...
</div>
);
return (
<List
itemsRenderer={renderList}
...
/>
);
}
Context (environment)
- Version: 3.0.9
- TypeScript: 3.8.3
- Platform: Win 10 64bit
Metadata
Metadata
Assignees
Labels
No labels