简体   繁体   English

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

[英]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.

相关问题 如何允许使用typescript错误进行javascript编译, - How to allow javascript compilation with typescript errors, 如何将 typescript 路径添加到故事书 - How to add typescript paths to storybook 故事书中的 Typescript 道具类型使用参数 - Typescript in storybook with props type using parameter 如何在 Typescript 中使用 composeWithDevTools createStore 而不会出现类型错误? - How to createStore with composeWithDevTools in Typescript without type errors? 如何使用 Tailwindcss、ReactJS 和 Typescript 设置 Storybook - How to setup Storybook with Tailwindcss, ReactJS and Typescript Typescript 中类型“boolean”不可分配给类型“StoryFnReactReturnType”React Storybook - Type 'boolean' is not assignable to type 'StoryFnReactReturnType' React Storybook in Typescript 如何让故事书在故事中显示打字稿类型 - How to get storybook to display typescript types in stories 如何在 TypeScript 中只允许 React HOC 的某个组件参数类型? - How to only allow a certain component parameter type for React HOC in TypeScript? 如何在 react 和 typescript 中扩展 forwardRef 的引用类型以允许多个引用 - How to extend a ref type for forwardRef in react and typescript to allow multiple refs 如何在 Storybook 6.0.0 中显示道具类型表 - How to display props type table in storybook 6.0.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM