preact
preact copied to clipboard
Improve react typescript compatibility
Fixed #1930
For clarity, I am trying to get an existing react project working with preact. I encountered a number of typescript incompatibilities as described in #1930 and attempted to fix them with the proposed changes.
I added the following in my tsconfig.json:
{
"compilerOptions": {
...
"paths": {
"react": ["node_modules/preact/compat/"],
"react-dom": ["node_modules/preact/compat/"]
}
}
}
And in package.json applied a browserify global transform using aliasify to alias react and react-dom to preact/compat.
Coverage remained the same at 99.798% when pulling 770ac2092568f9fffeb349c9e9c090987320fffd on bvella:improve-react-ts-compat into 020d5e599b8b84745932f092a835f494b1dd2261 on preactjs:master.
Incorporated https://github.com/preactjs/preact/issues/2150#issuecomment-558622551
I know it's been a while, there are some more types missing in #2414 if you want to add those
Any chance this could be merged? 👼
When using @apollo/client
ERROR in ./node_modules/@apollo/client/react/context/ApolloConsumer.d.ts(4,55):
TS2694: Namespace 'React' has no exported member 'ReactChild'.
I wasn't using this branch though, but I guess you need to add ReactChild
too ?
@bvella could you update this branch with the base branch so it can be re-approved and then released?
Any update on this? Is there a complete workaround with all the changes needed to perform to a Preact project to be able to use typed React libraries in it until it merged?
I would like to contribute to this effort.. I'm not sure how to do it besides creating a separate PR. Is that ok?