Closed SevenOutman closed 2 years ago
When the types are wrong, the most likely reason is that the types are wrong. A distant second is that the implementation is wrong.
In this case, if React and elementType are in sync, then it's the DT package that's got the issue ("nominalTypeHack" looks fishy to me)
Hi @ljharb , yes I think it's the types that are incompatible. @types/react
regards HTML element tags as union of a limited range of values, while @types/prop-types
regards it as plain string
. Is this repo the right place for raising issues for types?
The place to look for correctness js never the types - what does react do? Whatever that is, the types should match.
No, the DefinitelyTyped repo is basically always the right place for types (it’s best when even packages authored in TS don’t ship their own types, because it conflates the semver of the types and the actual important part, the implementation)
Alright. Just opened a thread in the DT repo https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/57143
Hi, I'm writing my components library in TypeScript and using
prop-types
in case users use my library with JavaScript. And my TypeScript is complaining thatReact.ElementType
andPropTypes.elementType
are not compatible.@types/react
version 17.0.3@types/prop-types
version 15.7.4It can be reproduced with this simple demo on CodeSandbox https://codesandbox.io/s/vibrant-burnell-xhksw?file=/src/Button.tsx