-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: forwardRef ignore Type Check #27558
Comments
cc @eps1lon – I guess the inferred type parameter here ends up as |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
The main problem here is that you can pass We may be able to fix this at the type level by defaulting the instance type to |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
React version: 18.2.0
TypeScript version: 5.2.2
Steps To Reproduce
forwardRef
ref
useImperativeHandle
useImperativeHandle
The reproducible code forked from here:
Link to code example:
https://codesandbox.io/p/sandbox/sweet-cloud-hn34vp
The current behavior
forwardRef
withForwardedRef<unknown>
does not cause any type error.Then an error occurs like below on run-time.
The expected behavior
forwardRef
components should cause an error when wrong type ref objects are passed through the parameterref
.It is so that we notice a mistake before run-time.
The text was updated successfully, but these errors were encountered: