Angular 8 和 Storybook 6 [英] Angular 8 with Storybook 6

查看:34
本文介绍了Angular 8 和 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 版本

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

开发依赖

    "@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"

推荐答案

作为一种解决方法,我更新了从 Button、Header、Page{.stories} 的导入:

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

这很好用.但不确定为什么样板代码有问题.:(这适用于 6.0.12 版.

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

更新:使用较新版本的故事书(> 6.2.*),在 .storybook 目录中的 Typings.d.ts 中显式声明.(@Mr.7 提到)

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'

这篇关于Angular 8 和 Storybook 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆