preact
preact copied to clipboard
fix(types): ensure `forwardRef` overrides the default ref type
This fixes an issue with forwardRef that was leading to a type conflict, which was basically…
(Ref<HTMLDivElement> | undefined) // …from forwardRef's return type
& (Ref<any> | undefined) // …from the RenderableProps type
Try to assign the ref prop of a forwardRef component to a ref callback, its argument's type defaults to any no matter the component type.
Reproduction
/* @jsxImportSource preact */
import { forwardRef } from "preact/compat";
declare class Element {}
const Foo = forwardRef<Element>(() => {
return <div />;
});
const element = <Foo ref={(node) => {}} />;
// ^? any (should be Element)
📊 Tachometer Benchmark Results
Summary
A summary of the benchmark results will show here once they finish.
Results
The full results of your benchmarks will show here once they finish.