Skip to content
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

Remove react from package.json #16629

Closed
wants to merge 1 commit into from
Closed

Conversation

upupming
Copy link

@upupming upupming commented Nov 8, 2021

Issue: vue and react type conflicts

What I did

Remove react from package.json to avoid vue 3 types conflict

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

This solves this problem:

image

import { Meta } from '@storybook/vue3'
<template>
  <div>
    <h2 class="font-semibold"> 
            |--> type error here: Type '{ class: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>'.
  Property 'class' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>'. Did you mean 'className'?
      Tech stack
    </h2>
  </div>
</template>

the HTMLAttributes from @vue/runtime-dom will be overriten by @types/react.

Currently the solutionn is to disable react types in your tsconfig.json file:

"paths": {
      "@/*": ["src/*"],
      // disable react types as a work around for: https://github.com/storybookjs/storybook/pull/16629
      // https://github.com/Microsoft/TypeScript/issues/17042#issuecomment-327882577
      "react": [".sink.d.ts"]
    },

And create ann empty .sink.d.ts file i your directory.

@nx-cloud
Copy link

nx-cloud bot commented Nov 8, 2021

Nx Cloud Report

We didn't find any information for the current pull request with the commit d480263.
You might need to set the 'NX_BRANCH' environment variable in your CI pipeline.

Check the Nx Cloud Github Integration documentation for more information.


Sent with 💌 from NxCloud.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that @storybook/vue3 actually depends on React since that's what we use to show the UI. This probably won't be the case in 7.0, so we should be able to clean up these dependencies then. @tmeasday WDYT?

@tmeasday
Copy link
Member

tmeasday commented Nov 8, 2021

I'm not sure why the package has to depend directly on react @shilman? But, as you say, I don't think removing it will make a difference as other sub-dependencies do depend on react, such as @storybook/ui.

@upupming
Copy link
Author

upupming commented Nov 8, 2021

Now that storybook itself relies on react, I think it should not ship @types/react when in production.

I do a dependency list for @types/react, it seems @storybook/components use @types/react-syntax-highlighter as dependenncy instead of devDependenncy. We can remove @types/react-syntax-highlighter to devDependenncy, what do you thinnk? @shilman

❯ pnpm why @types/react
Legend: production dependency, optional only, dev only

[email protected] /Users/upupming/projects/vue3-compact-template

devDependencies:
@storybook/addon-actions 6.4.0-beta.23
└─┬ @storybook/components 6.4.0-beta.23
  └─┬ @types/react-syntax-highlighter 11.0.5
    └── @types/react 17.0.33
@storybook/addon-essentials 6.4.0-beta.23
├─┬ @storybook/addon-actions 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
├─┬ @storybook/addon-backgrounds 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
├─┬ @storybook/addon-controls 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
├─┬ @storybook/addon-docs 6.4.0-beta.23
│ ├─┬ @storybook/builder-webpack4 6.4.0-beta.23
│ │ ├─┬ @storybook/components 6.4.0-beta.23
│ │ │ └─┬ @types/react-syntax-highlighter 11.0.5
│ │ │   └── @types/react 17.0.33
│ │ └─┬ @storybook/ui 6.4.0-beta.23
│ │   └─┬ @storybook/components 6.4.0-beta.23
│ │     └─┬ @types/react-syntax-highlighter 11.0.5
│ │       └── @types/react 17.0.33
│ ├─┬ @storybook/components 6.4.0-beta.23
│ │ └─┬ @types/react-syntax-highlighter 11.0.5
│ │   └── @types/react 17.0.33
│ ├─┬ @storybook/core 6.4.0-beta.23
│ │ ├─┬ @storybook/core-client 6.4.0-beta.23
│ │ │ └─┬ @storybook/ui 6.4.0-beta.23
│ │ │   └─┬ @storybook/components 6.4.0-beta.23
│ │ │     └─┬ @types/react-syntax-highlighter 11.0.5
│ │ │       └── @types/react 17.0.33
│ │ └─┬ @storybook/core-server 6.4.0-beta.23
│ │   ├─┬ @storybook/builder-webpack4 6.4.0-beta.23
│ │   │ ├─┬ @storybook/components 6.4.0-beta.23
│ │   │ │ └─┬ @types/react-syntax-highlighter 11.0.5
│ │   │ │   └── @types/react 17.0.33
│ │   │ └─┬ @storybook/ui 6.4.0-beta.23
│ │   │   └─┬ @storybook/components 6.4.0-beta.23
│ │   │     └─┬ @types/react-syntax-highlighter 11.0.5
│ │   │       └── @types/react 17.0.33
│ │   ├─┬ @storybook/core-client 6.4.0-beta.23
│ │   │ └─┬ @storybook/ui 6.4.0-beta.23
│ │   │   └─┬ @storybook/components 6.4.0-beta.23
│ │   │     └─┬ @types/react-syntax-highlighter 11.0.5
│ │   │       └── @types/react 17.0.33
│ │   └─┬ @storybook/manager-webpack4 6.4.0-beta.23
│ │     ├─┬ @storybook/core-client 6.4.0-beta.23
│ │     │ └─┬ @storybook/ui 6.4.0-beta.23
│ │     │   └─┬ @storybook/components 6.4.0-beta.23
│ │     │     └─┬ @types/react-syntax-highlighter 11.0.5
│ │     │       └── @types/react 17.0.33
│ │     └─┬ @storybook/ui 6.4.0-beta.23
│ │       └─┬ @storybook/components 6.4.0-beta.23
│ │         └─┬ @types/react-syntax-highlighter 11.0.5
│ │           └── @types/react 17.0.33
│ └─┬ @storybook/vue3 6.4.0-beta.23 peer
│   └─┬ @storybook/core 6.4.0-beta.23
│     ├─┬ @storybook/core-client 6.4.0-beta.23
│     │ └─┬ @storybook/ui 6.4.0-beta.23
│     │   └─┬ @storybook/components 6.4.0-beta.23
│     │     └─┬ @types/react-syntax-highlighter 11.0.5
│     │       └── @types/react 17.0.33
│     └─┬ @storybook/core-server 6.4.0-beta.23
│       ├─┬ @storybook/builder-webpack4 6.4.0-beta.23
│       │ ├─┬ @storybook/components 6.4.0-beta.23
│       │ │ └─┬ @types/react-syntax-highlighter 11.0.5
│       │ │   └── @types/react 17.0.33
│       │ └─┬ @storybook/ui 6.4.0-beta.23
│       │   └─┬ @storybook/components 6.4.0-beta.23
│       │     └─┬ @types/react-syntax-highlighter 11.0.5
│       │       └── @types/react 17.0.33
│       ├─┬ @storybook/core-client 6.4.0-beta.23
│       │ └─┬ @storybook/ui 6.4.0-beta.23
│       │   └─┬ @storybook/components 6.4.0-beta.23
│       │     └─┬ @types/react-syntax-highlighter 11.0.5
│       │       └── @types/react 17.0.33
│       └─┬ @storybook/manager-webpack4 6.4.0-beta.23
│         ├─┬ @storybook/core-client 6.4.0-beta.23
│         │ └─┬ @storybook/ui 6.4.0-beta.23
│         │   └─┬ @storybook/components 6.4.0-beta.23
│         │     └─┬ @types/react-syntax-highlighter 11.0.5
│         │       └── @types/react 17.0.33
│         └─┬ @storybook/ui 6.4.0-beta.23
│           └─┬ @storybook/components 6.4.0-beta.23
│             └─┬ @types/react-syntax-highlighter 11.0.5
│               └── @types/react 17.0.33
├─┬ @storybook/addon-measure 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
├─┬ @storybook/addon-outline 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
├─┬ @storybook/addon-toolbars 6.4.0-beta.23
│ └─┬ @storybook/components 6.4.0-beta.23
│   └─┬ @types/react-syntax-highlighter 11.0.5
│     └── @types/react 17.0.33
└─┬ @storybook/addon-viewport 6.4.0-beta.23
  └─┬ @storybook/components 6.4.0-beta.23
    └─┬ @types/react-syntax-highlighter 11.0.5
      └── @types/react 17.0.33
@storybook/vue3 6.4.0-beta.23
└─┬ @storybook/core 6.4.0-beta.23
  ├─┬ @storybook/core-client 6.4.0-beta.23
  │ └─┬ @storybook/ui 6.4.0-beta.23
  │   └─┬ @storybook/components 6.4.0-beta.23
  │     └─┬ @types/react-syntax-highlighter 11.0.5
  │       └── @types/react 17.0.33
  └─┬ @storybook/core-server 6.4.0-beta.23
    ├─┬ @storybook/builder-webpack4 6.4.0-beta.23
    │ ├─┬ @storybook/components 6.4.0-beta.23
    │ │ └─┬ @types/react-syntax-highlighter 11.0.5
    │ │   └── @types/react 17.0.33
    │ └─┬ @storybook/ui 6.4.0-beta.23
    │   └─┬ @storybook/components 6.4.0-beta.23
    │     └─┬ @types/react-syntax-highlighter 11.0.5
    │       └── @types/react 17.0.33
    ├─┬ @storybook/core-client 6.4.0-beta.23
    │ └─┬ @storybook/ui 6.4.0-beta.23
    │   └─┬ @storybook/components 6.4.0-beta.23
    │     └─┬ @types/react-syntax-highlighter 11.0.5
    │       └── @types/react 17.0.33
    └─┬ @storybook/manager-webpack4 6.4.0-beta.23
      ├─┬ @storybook/core-client 6.4.0-beta.23
      │ └─┬ @storybook/ui 6.4.0-beta.23
      │   └─┬ @storybook/components 6.4.0-beta.23
      │     └─┬ @types/react-syntax-highlighter 11.0.5
      │       └── @types/react 17.0.33
      └─┬ @storybook/ui 6.4.0-beta.23
        └─┬ @storybook/components 6.4.0-beta.23
          └─┬ @types/react-syntax-highlighter 11.0.5
            └── @types/react 17.0.33

Update: I have opened another PR to fix this: #16630

@upupming upupming closed this Nov 8, 2021
XavierChevalier pushed a commit to XavierChevalier/jam that referenced this pull request Nov 26, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants