Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 8 with Storybook 6

Getting the below error while installing and starting a storybook.

ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts
ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts(2,29):
TS2307: Cannot find module '@storybook/angular/types-6-0'.

ng version

Angular CLI: 8.3.29
Node: 12.16.2
OS: darwin x64
Angular: 8.2.14

Dev dependency

    "@compodoc/compodoc": "^1.1.11",
    "@storybook/addon-actions": "^6.0.12",
    "@storybook/addon-essentials": "^6.0.12",
    "@storybook/addon-links": "^6.0.12",
    "@storybook/angular": "^6.0.12"
like image 796
Subhakant Priyadarsan Avatar asked Aug 18 '20 05:08

Subhakant Priyadarsan


2 Answers

As a workaround, I have updated the imports from Button, Header, Page{.stories}:

From --->
import { Story, Meta } from '@storybook/angular/types-6-0';

To  ---->
import { Story, Meta } from '@storybook/angular';

This works fine. But not sure why the boilerplate code has the issue. :( This works fine with version 6.0.12.

Updates: With newer version of the storybook(>6.2.*), Explicitly declare in typings.d.ts inside the .storybook directory. (mentioned by @Mr.7)

declare module '@storybook/angular'
like image 159
Subhakant Priyadarsan Avatar answered Oct 20 '22 13:10

Subhakant Priyadarsan


In my case, I tried Subhakant's workaround but that didn't work for me. After some research I found this.

The explicit declaration in typings.d.ts inside .storybook directory made it work

declare module '@storybook/angular'

like image 36
Mr.7 Avatar answered Oct 20 '22 13:10

Mr.7