Search code examples
angularstorybookintershop

Storybook not working in Angular Intershop Project


When I try to add storybook to an Angular Intershop Project with this command npx -p @storybook/cli sb init --type angular and then run npm run storybook, it gives me this error:

ERROR in D:/angular-intershop/intershop-pwa/src/stories/0-Welcome.stories.ts
ERROR in D:/angular-intershop/intershop-pwa/src/stories/0-Welcome.stories.ts(1,25):
TS2307: Cannot find module '@storybook/angular/demo'.

ERROR in D:/angular-intershop/intershop-pwa/src/stories/1-Button.stories.ts
ERROR in D:/angular-intershop/intershop-pwa/src/stories/1-Button.stories.ts(4,24):
TS2307: Cannot find module '@storybook/angular/demo'.

Do you know what is missing? Thank you

Storybook Angular Intershop Error

And I have this in my demo.d.ts file

declare module '@storybook/angular/demo' { export const Button: any; export const Welcome: any; }


Solution

  • Just to get it 'working' can you try the following:

    • add the declare module '@storybook/angular/demo' to src/typings.d.ts.
    • add "../src/setupJest.ts" to the "exclude" array in .storybook/tsconfig.json so storybook ignores the types used there

    (edit: included correct answer for excluding collision with jest types)