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

Type error when using the lib with @types/react@18.3.0 and @types/react-dom@18.3.0 #80

Open
adrianorocha-dev opened this issue Apr 25, 2024 · 1 comment

Comments

@adrianorocha-dev
Copy link

I recently updated react and react-dom to their latest versions, and I ran into the following error when compiling my project:
Type '(input: HTMLInputElement | null) => HTMLInputElement | null | undefined' is not assignable to type '((instance: HTMLInputElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLInputElement> | null | undefined'.

I went into the .d.ts file to investigate, and I was able to solve the problem by changing the withMask type from:

declare const withMask: (mask: Mask, options?: Options) => (input: Input) => Input;

to:

declare const withMask: (mask: Mask, options?: Options) => (input: Input) => void;
@adrianorocha-dev
Copy link
Author

I was reading about the upcoming React 19 update, and found something that maybe related.
https://react.dev/blog/2024/04/25/react-19#cleanup-functions-for-refs
Apparently refs will now support cleanup function and as such, we cannot return anything other than a function from a ref function. Maybe the react types has already updated to reflect that.

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

No branches or pull requests

1 participant