Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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; }

like image 903
Mónica Fidalgo Avatar asked Mar 03 '20 11:03

Mónica Fidalgo


2 Answers

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)

like image 120
Danilo Hoffmann Avatar answered Sep 19 '22 16:09

Danilo Hoffmann


just add "../src/setupJest.ts" to the "exclude" array in .storybook/tsconfig.json

like image 21
Sebastian Hähnlein Avatar answered Sep 16 '22 16:09

Sebastian Hähnlein