-
-
Notifications
You must be signed in to change notification settings - Fork 148
Module aliasing in TypeScript without WebPack #471
Comments
Having |
@marvinhagemeister forgive me if it's a dumb question, I'm relatively new to TypeScript, does that imply that (at least for now) preact-compat with TypeScript is a no-go and one should go with vanilla preact? |
@bard |
So, it appears I was barking wildly up the wrong tree. Parcel does its own resolution and aliasing modules is as easy as placing this in
Everything runs smoothly after that, even keeping Would you guys consider adding that bit to https://preactjs.com/guide/switching-to-preact? |
@bard awesome, that's even better 🎉 Filed an issue over at |
I want to alias
preact-compat
toreact
. I'm not using WebPack, I'm using Parcel which in turn is letting TypeScript do its own module resolution.I'm 50% there but type definitions are getting in the way (see below).
Details:
react
andreact-dom
are aliased topreact-compat
via thepaths
property intsconfig.json
:The compiler tries resolving
react
, looks atnode_modules/react
as per default, finds nothing, looks at the value ofpaths
above, triesnode_modules/preact-compat
, finds it and accepts it:So far, so good.
However if I install
@types/react
and retry the above...Ouch,
react
is now resolved to@types/react/index.d.ts
.How to keep types installed and still have
react
alias topreact-compat
?(I realize this is more of a TypeScript question but given the use case perhaps someone has come across and solved this already.)
The text was updated successfully, but these errors were encountered: