繁体   English   中英

即使出现 TypeScript(类型)错误,如何允许故事书构建?

[英]How to allow storybook to build even with TypeScript (type) errors?

我已经设置了 CRA 打字稿模板并将故事书集成到应用程序中。 我正在使用 Chakra-UI,它现在缺少对一些组件的打字稿支持。 当我运行 yarn storybook 时,该应用程序会运行并提供故事书应用程序,并且所有组件故事都运行良好。 但是,当我使用命令 yarn build-storybook 进行构建时,控制台中会显示 TypeScript 错误,并且该命令以退出代码 1 退出,并且构建从未发生。 如何设置配置,即使认为存在 TS 错误,故事书仍然继续构建?

下面的示例错误。

在此处输入图片说明

Storybook v6.1+ main.ts / main.js

module.exports = {
    typescript: {
        check: false
    }
    ...
}

来源: https : //storybook.js.org/docs/react/configure/typescript

您的 tsconfig 中有很多严格的类型检查选项,可以禁用它们以防止出现这些错误。

/* Strict Type-Checking Options */
    // "strict": true,                        /* Enable all strict type-checking options. */
    // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
    // "strictNullChecks": true,              /* Enable strict null checks. */
    // "strictFunctionTypes": true,           /* Enable strict checking of function types. */
    // "strictBindCallApply": true,           /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
    // "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */
    // "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
    // "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

对于您的具体情况,您可以在失败的行上方键入以下内容。 (包括“//”)

// @ts-ignore

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM