[英]How to allow storybook to build even with TypeScript (type) errors?
I've set up CRA typescript template and integrated storybook into the app.我已经设置了 CRA 打字稿模板并将故事书集成到应用程序中。 I'm using Chakra-UI which lacks typescript support for a few components right now.
我正在使用 Chakra-UI,它现在缺少对一些组件的打字稿支持。 When I run yarn storybook, the app runs and serves up the storybook app and all the component stories work fine.
当我运行 yarn storybook 时,该应用程序会运行并提供故事书应用程序,并且所有组件故事都运行良好。 When I build though, with the command yarn build-storybook, the TypeScript errors show up in the console and the command exits with exit code 1 and the build never happens.
但是,当我使用命令 yarn build-storybook 进行构建时,控制台中会显示 TypeScript 错误,并且该命令以退出代码 1 退出,并且构建从未发生。 How do I set a configuration such that even thought there are TS errors, storybook still proceeds with the build?
如何设置配置,即使认为存在 TS 错误,故事书仍然继续构建?
Sample error below.下面的示例错误。
Storybook v6.1+ main.ts
/ main.js
Storybook v6.1+
main.ts
/ main.js
module.exports = {
typescript: {
check: false
}
...
}
source: https://storybook.js.org/docs/react/configure/typescript来源: https : //storybook.js.org/docs/react/configure/typescript
There are plenty of strict type checking options in your tsconfig which may be disabled to prevent those errors.您的 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. */
For your specific case you may just type the following above the failing line.对于您的具体情况,您可以在失败的行上方键入以下内容。 (Incl. '//')
(包括“//”)
// @ts-ignore
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.