For @mdx-js/react
, move @types/react
from dependencies
to peerDependencies
#2238
Unanswered
unrevised6419
asked this question in
General
Replies: 1 comment 32 replies
-
Hey!
mdx/packages/react/lib/index.js Line 2 in f4d78be Without it, this project can’t be used in TypeScript. |
Beta Was this translation helpful? Give feedback.
32 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the
@mdx-js/reaact
is mentioned this:So it says that the developer itself should install the JSX types he needs,
@types/react
or maybe others like@vue/runtime-dom
But there is a problem,
@types/react
is included in packagedependencies
, and is creating conflicts with other JSX types, like@vue/runtime-dom
, because TypeScript prefers as default@types/react
, if it will find it innode_modules
From where this discussion was born?
When having a Vue/Nuxt project, it recommends using
Volar
extensions that will deal great with TypeScript and adds@vue/runtime-dom
JSX types by default implicitly.At the moment you want to integrate Storybook, the problem appears, because it will add
@types/react
as a transitive dependency from@mdx-js/react
Now TypeScript will see
@types/react
innode_modules
and all your JSX in Vue will be Typed as React.The current solution is to do some hacks to stub
@types/react
to an empty packageNow TypeScript will see that there is not JSX namespace in
@types/react
and will go back to using@vue/runtime-dom
The suggestion from our side would be to move
@types/react
fromdependencies
todevDependencies
so it wont become a transitive dependency.This was discussed in depth in some threads:
Beta Was this translation helpful? Give feedback.
All reactions