Closed gaetanmaisse closed 5 years ago
Perhaps there are some deeper issues. I think we should make our typing resilient and less duplicated. I personally not encourage inline typing and more favour using type
for function and interface
for class (well, maybe just using type
to leverage the union typing in TS). And in most of time, using type inferences and reduce the need to type everything in great details.
Most of file will be modularized, which makes typing also modularized and potentially cyclic referenced (but we only need to get the type...). That is how I see why migrate to TS get weird errors. Why not just have a file just for typing?! Maybe less intuitive/convenient but I think the we should not mix type mingle with its implementation.
Here is my approach in addon-contexts
. I basically separate the implementation and typing. And by doing so, I have been able to think in abstraction, reduced the noise at the same time.
I think we DO NOT have any production cyclic dependencies. it's devDependencies that make things cyclical.
The solution is likely to not include the devDependencies in the package.json
of @storybook/components
.
Because they are guaranteed to be there when developing in the monorepo.
Essentially all devDependencies could be in the package.json in the root, and our own packages don't need to appear in package.json if they are ONLY used during dev on that package.
@ndelangen Yes exactly it's only due to devDependencies
!
The solution is likely to not include the devDependencies in the package.json of @storybook/components.
I'm ok with that and already tried it 😉 by doing so it raises ts-lint error no-implicit-dependencies. BUT I just found that we can, fortunately, add a whitelist of modules that will be skipped during ts-lint check.
So if you're ok, I will add a commit to https://github.com/storybooks/storybook/pull/6500 to remove @storybook/addon-actions
and @storybook/react
from devDependencies of @storybook/components
and add them to tslint whitelist.
Sounds good!
Storybook monorepo contains some cyclic dependencies, they are listed during
yarn bootstrap
:These cyclic dependencies caused some build to fails because lerna doesn't know which libs should be built first. It was not a big deal when SB was fully JS but since we have some libs in TS type checking during compilation is failing, causing the full build to fail too. For instance, this build linked to https://github.com/storybooks/storybook/pull/6500.
In fact, there are cyclic dependencies mainly because
@storybook/components
has@storybook/addon-actions
and@storybook/react
asdevDependencies
(and the latter finally depends on@storybook/components
) because we have stories for almost all components from@storybook/components
. I'm a big fan of having stories in the same folder as the components they describe but it looks like it's causing some trouble in our case...As more and more parts of SB will be migrated to TS I think we should discuss and try to find solutions about this.
--
🤷♂️ Not sure which tags I should put on this issue