-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[compat types] - issue with the element's type like button, that gets any instead of ButtonHTMLAttributes #4099
Labels
Comments
Has this issue been resolved? |
@victor-williams I'm waiting for approval, If you can't wait, You can take the new codes and put into the reactCompat.d.ts in your project until this merge. |
I'm also blocked on this. |
rschristian
added a commit
that referenced
this issue
Jul 1, 2024
…s-types type[compat]: add html attributes types #4099
Merged
This was referenced Aug 14, 2024
This was referenced Sep 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The issue is with some conflicts type of compat with React types, when other libraries trying to using the react types inner like: styled-components.
For some elements react has special type like this line: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f701ddcb5bec7d89238b8f1b9d362a20ff9c8e94/types/react/v17/index.d.ts#L2048
So as you can see there is an error for h1 but for button there isn't and it takes
any
So i checked the styled-component that give the button this type.
button: Styled<"web", "button", import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, import("../types").BaseObject>;
But after using aliases of compat, it will be something like this:
button: Styled<"web", "button", **any**, import("../types").BaseObject>;
Because styled component trying to access to ButtonHTMLAttributes, but this type doesn't exist in the compact so it takes any.
To Reproduce
If possible, please provide a CodeSandbox/Codepen that demonstrates the issue. You can use the following template: https://codesandbox.io/s/preact-x-preact-cli-3-starter-vj285y2rn3
I can't do it, Because for displaying the errors needs more typescript configuration but i explain it here:
Steps to reproduce the behavior:
checker({ typescript: true })
preact({ babel: { plugins: [ [ "babel-plugin-styled-components", { pure: true, displayName: false, fileName: false, }, ], ], }, }),
Then add ThemeProvider and styled.d.ts like this codesandbox.
https://codesandbox.io/s/interesting-hooks-5m8kvr?file=/src/App.tsx
After that If you create those components in the screenshot you can see h1 has correct type but button doesn't have.
Expected behavior
What should have happened when following the steps above?
The text was updated successfully, but these errors were encountered: