I am starting a webapp using preact with typescript and parcel as a bundler.
I'd like to avoid using preact-specific imports, so (as per the parcel docs) I added this parcel-specific configuration to my package.json:
"alias": {
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime"
},
With that configuration, this import works fine when the application is compiled/started with parcel:
import * as React from "react";
However, the typescript language service and therefore IDEA is highlighting it as an error
TS2307: Cannot find module 'react' or its corresponding type declarations
which is understandable, of course, because typescript does not know about parcel specific stuff.
My current workaround is to also have react installed in devDependencies in addition to preact in dependencies. That just feels wrong. Is there another option?