-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
@storybook/react types dependency @types/webpack-env conflicting with @types/node #9241
@storybook/react types dependency @types/webpack-env conflicting with @types/node #9241
Comments
Having the same exact issue with the same system. Also building a typescript project. The only way I was able to get my project to build was making skiLibCheck in tsconfig to true. |
Having to revert @types/node to version 12.12.18, the project builds fine. would be nice to get a fix on this. |
Here’s the problem. The package Another package, For all intents and purposes, these two “environments” do not exist at the same time at runtime. Code that is bundled with webpack is going to use webpack’s However, it’s often the case that TypeScript projects end up with both environments’ global declarations at the same time. This is happening to @storybook/react because it contains server code that references node built-ins like /// <reference types="node" />
/// <reference types="webpack-env" /> Now, any TypeScript user who imports Ok, so why did this blow up all of a sudden? Last week, I merged an update from a @types/node contributor on DefinitelyTyped adding typings for node 13. That update made minor changes to the shape of some of the same globals that @types/webpack-env declares. When a global interface is declared two different times in the same TypeScript program, they get merged together, but if both interfaces declare the same property, the type of that property must be identical between the two declarations. When @types/node was updated, those interfaces were no longer mergeable with the ones in @types/webpack-env. So, there are potentially two paths forward here:
In a perfect world, the former would not matter at all. Since code doesn’t use webpack’s loader system and node’s loader system at the same time, why would it matter if those two packages can coexist cleanly? But in the real world, it seems that an effort has been made in the past to keep webpack-env from clobbering node, since this problem is so common. So, we should probably pursue this course of action if possible. But, we should investigate the latter as well. Users need some way of isolating the types for node and the types for webpack from each other, and right now @storybook/react (and @storybook/types) are making it impossible to create that boundary. This probably means splitting client and server into separate TypeScript projects throughout Storybook. (And if it was intentional to require users to have @types/node installed, then it needs to be listed as a dependency or peerDependency.) Unfortunately, I’m not a Storybook user, so I’m afraid I don’t know enough about how and where users import things from different Storybook packages to be able to do this myself. But I’m happy to help out with knowledge from the TS side. |
Same issue in @storybook/[email protected] and @storybook/[email protected]; setting skipLibCheck in {
"...":"...",
"compilerOptions": { "skipLibCheck": true },
"...":"..."
} |
Describe the bug
@storybook/react
types dependency@types/webpack-env
conflicting with@types/node
To Reproduce
Steps to reproduce the behavior:
Screenshots
System:
Additional context
Manually editing @types/webpack-env solves this problem.
I tried adding "types" to tsconfig.json to limit type definition scope.
I am using storybook in monorepo setup using yarn.
The text was updated successfully, but these errors were encountered: