-
-
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
Aliasing 'react' to 'preact/compat' when migrating from React (typescript) #3350
Comments
Hmm, odd normally you don't have to do anything in TypeScript, especially not creating path aliases 😅 |
Maybe I wasn't completely clear, the project was running on React, so it has |
I mean, it doesn't have to as |
I'm sorry, what you're saying doesn't make any sense to me. I realize that |
Yes, but TypeScript is mainly an IDE tool so it doesn't actually need to know that 😅 you can just let it think you are importing from React as it won't affect your ending bundle unless you're using it to get the end bundle which in terms of bundle size I'd advise against. https://www.npmjs.com/package/@rollup/plugin-alias is better for that alias stuff |
I should have mentioned, that I do use rollup.config.js
It's just it's not enough on it's own, I still have to add aliasing in |
Ah yes, my solution assumes that you just leave react(-dom) installed as it doesn't really matter if it's a node_module 😅 haven't really done the ts-path aliases as I find them quite flakey |
So, could you explain, how migration supposed to be done? Should I leave |
Oh, I think I'm starting to understand. I don't need to install actual packages, just the types. After installing |
@JoviDeCroock thank you for the answers. |
My project uses rollup+ts. When switching from React to preact I had to do the following in order to make the project compile
tsconfig.json
This seems a bit odd to me. Is this how it was intended? I thought
preact-compat
is deprecated, but if I usepreact/compat
instead, then there's some types missing, likeJSX.Element
andReact.DependencyList
and many others. I think it's related to #2222 and #2150.And the first alias cannot be changed from
preact/compat
topreact-compat
either, otherwise ts complains to that line:In the end, it all works and it's maybe not a big deal, but I think this should be documented at the very least.
The text was updated successfully, but these errors were encountered: