Skip to content
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

forwardedRef incorrectly typed #393

Closed
oscar-b opened this issue Oct 16, 2020 · 4 comments · Fixed by #396
Closed

forwardedRef incorrectly typed #393

oscar-b opened this issue Oct 16, 2020 · 4 comments · Fixed by #396

Comments

@oscar-b
Copy link

oscar-b commented Oct 16, 2020

Describe the bug
The prop forwardedRef, introduced here: https://github.com/FortAwesome/react-fontawesome/pull/341/files#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8R24 seems to be incorrectly typed compared to React:

Type '((instance: unknown) => void) | MutableRefObject<unknown> | null' is not assignable to type '((e: any) => void) | RefObject<any> | undefined'.
  Type 'null' is not assignable to type '((e: any) => void) | RefObject<any> | undefined'.

The ref prop from React.forwardRef is typed like this:

(parameter) ref: ((instance: unknown) => void) | React.MutableRefObject<unknown> | null

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L565

The forwardedRef prop from <FontAwesomeIcon /> expects the prop to be optional, not possibly null.

Reproducible test case
https://codesandbox.io/s/confident-http-bpf4y?file=/src/Icon.tsx

Expected behavior
No type error.

Desktop (please complete the following information):

"@fortawesome/react-fontawesome": "^0.1.11",
"react": "^16.13.1",

Additional context
Add any other context about the problem here.

@TiagoPortfolio
Copy link
Contributor

Any update on this?

@robmadole
Copy link
Member

PR's are welcome on this. We don't use TypeScript so we lean pretty heavily on the community to update this.

@TiagoPortfolio
Copy link
Contributor

PR's are welcome on this. We don't use TypeScript so we lean pretty heavily on the community to update this.

I opened a PR #396

@robmadole
Copy link
Member

Thanks @TiagoPortfolio . Merged and released 0.1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants