-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Make JSX typings an optional install as they conflict with React TSX #1033
Comments
I could see this problem be solved temporarily by resynchronizing the types of react and vue. |
But are you going to use JSX/TSX in Vue, or are you going entirely with templates? While this does make it compile, you still wouldn't be able to use Vue TSX until you completely remove React typings? |
Agreed, and choose when to do this switch from React JSX to Vue JSX. What do you suggest? a bit of contextVue-styleguidist uses React to render a style guide for VueJs components. Most of the code is in react though. Vue only comes in play in the preview. The reason being, same as for storybook, that the original product was written in react. Should I rewrite it completely using Vue? Though there is a project started for that, I feel like I am letting my users down changing technology suddenly. Since all customizations of styleguidist was done in react before, it would be better to be able to at least choose when they switch. Really looking forward to your opinion. |
I could create a Pull Request to expose what I think could be useful. |
@shilman, @Aaron-Pool Did you experience the same kind of issue implementing vue-next in storybook? |
The main conflict seems to be about Another solution might be to share the definition of the This way, TSX conflicts will be avoided until one chooses to switch from react TSX to vue TSX. |
@elevatebart we haven't yet implemented vue-next in storybook. you're in uncharted territory! 😄 |
@elevatebart Same here, the furthest I've gone is using jsx with the Vue 2.x composition-api plugin. Haven't started to explore the vue-next waters just yet. |
Hello @DanielRosenwasser, Does TypeScript have a solution to deal with JSX ambient types conflicting? What solutions do you see? |
Either vue or react not both. Use storybook for your components doc. |
@martinoppitz I do not understand. Do you mean that preact typings are different from react typings? What do you suggest I do in a monorepo that has both react and Vuejs ? |
React and VueJs are not in the same package in the above monorepo. |
I think the ide does not differnce beetween the subfolder projects. Thank you for this perspective ... because I believe/feel "mono repos are a other name for monoliths." try to reduce the overhead by managing the independent packages ... a go back to move all in only one repo. If you are disciplined, then you can also properly design/develop monoliths. |
Thank you @martinoppitz, I understand your disliking for monorepos. They can create monoliths that are long to clone and even longer to install. In our case though, the vue-next monorepo could save our bacon. It allows easy extraction of a package in a PR. Once the PR is accepted, all 3 modified packages are delivered at once. No downtime when packages are incompatible or missing a library and e2e testing can continue without breaking. Regarding JSX, can you expand a little what I should do? I would not expect The Progressive JavaScript Framework to force a complete rewrite of the code upon adoption if there is another solution. |
@elevatebart just so you know I'm considering doing this, but still trying to figure out the best way to organize it with the upcoming Vue 3 JSX transform. |
Thank you @yyx990803, this will help a lot. Except for this hiccup, the migration to Vue 3 is bringing a lot of performance to docgen and styleguidist. I like it. |
FYI, namespace And TypeScript uses "jsxFactory": "VueJSX" |
I create a vue project with vue-cli. the project has a dependency of package named B. B has a dependency with react types. import type { PropsWithChildren } from 'react'; then my project emit errors:
here is my code: import { defineComponent, ref } from 'vue';
import style from './index.module.less';
export default defineComponent({
setup() {
const activeTab = ref('tab-one');
return () => (
<div
class={style.detail}
>
xxxx
</div>
)
},
}); I strive for solving this, what can I do with this situation? remove the package which has a dependency with react library, the error disappear.
|
I started getting these errors after installing storybook 3.6.10. My project's stack is vite + vue3 (typescript), while storybook is using webpack and is based on react, so I'm making a wild guess that by adding storybook, these errors started surfacing because of react dependencies. Type '{ class: string; }' is not assignable to type 'DetailedHTMLProps<OlHTMLAttributes, HTMLOListElement>'.\n Property 'class' does not exist on type 'DetailedHTMLProps<OlHTMLAttributes, HTMLOListElement>'. Did you mean 'className'?" |
@olemarius did you find more info on this? |
I have a monorepo with one package depending on Vue and other on react. I use pnpm which does not hoists dependencies. Then I have a tsconfig.json for each package. Hence, no JSX conflicts. But If I have to use Vue and react in same package/file, avoiding conflict is not possible. |
@olemarius Did you find a way to resolve this I'm having the same problem with Vue and Storybook setup with vite + vue3? |
I had the same problem |
Refs: //github.com/storybookjs/storybook/pull/16629,//github.com/storybookjs/storybook/pull/16630,//github.com/vuejs/core/issues/1033,//github.com/storybookjs/storybook/issues/12505,//github.com/XavierChevalier/ewokify-app/runs/4326759026?check_suite_focus=true
same problem @yyx990803 |
Hi, Try this in your tsconfig.json file "exclude": [
"**/node_modules",
"**/dist",
// https://github.com/johnsoncodehk/volar/discussions/592
"**/*.stories.ts"
] |
Thanks olemarius. Adding this fixed it
|
For me latest |
I deleted the |
I was playing with Storybook's new Interaction Testing (Vue/Vite builder) and I started seeing these issues about JSX as well in my Vue components. Upon uninstalling the dependencies (and re-installing the |
There is actually a way to make JSX namespace "local". It could be a namespace attached to the I've explored this quite a bit and I'm also advocating for I'm happy to discuss this further if you'd like to resolve this here once and for all, I could even prepare a PR for this. I'm not a Vue user though and I lack certain expertise when it comes to understanding the butterfly effect of such a change. So if the team here would be willing to discuss this - let me know and we could go through this together to recheck if such a change could be introduced in a backwards-compatible manner. |
With the lack of traction on this issue, I think we should be OK closing it. The brittle workaround is to use It works, with the caveat that every time we update vue, we have to re-write the patch. PNPM has an equivalent |
IMHO the issue should stay open because it's still valid. As mentioned in the past - I'm willing to work on this if somebody green lights this. I would probably also need to chat with the maintainers before getting to work because we'd need to establish the risks, breakage concerns, potential migration strategies etc |
guys ,add at the head of the file /* @jsxImportSource @vue/runtime-dom */ or tsconfig.json
{
...
"types": ["vue"],
} I test it works |
Thank you @zoy-l i did not know about this "trick". Will try it out. I ended up segregating the two code-bases using tsconfig reference. |
In our project, we're using TSX files as a nice way to write vanilla HTML outside of the Vue ecosystem (for performance reasons), which — not incorrectly — uses a syntax which is incomaptible with Vue syntax. The Vue docs even state:
Shouldn't it follow that |
Using this thread to remind that because of those jsx types clobbering the global namespace (on vue 2.7.13 at least), React and Vue cannot be used on the same project which is a real problem. |
That's exactly what happened to me as well. As below, React and Vue have different global namespace JSX types. And that's where type collision occurs. |
Version
3.0.0-beta.3
Reproduction link
https://github.com/elevatebart/vue-next-react-ts-conflict
Steps to reproduce
The errors you see in the console are due to React and Vue TSX accepting different values.
What is expected?
When migrating from React to Vue, types should not fail without installing them.
What is actually happening?
it fails at compilation
JSX types could be made a separate package:
@vue/jsx-types
.This way, types would not systematically be installed.
Devs could install the runtime they need without the typings.
The transition would be easier.
The text was updated successfully, but these errors were encountered: