如何禁用所有打字稿类型检查?

新手上路,请多包涵

我想 在未来 使用 TypeScript,但现在,我选择在 Create React App 中安装 TypeScript。 (后面我会回去添加类型)

因此,我想禁用所有类型检查。

现在,当我做这样的事情时:

 <PlaceSearchBar
    placeSearchChanged={this.placeSearchChanged}
/>

class PlaceSearchBar extends React.Component {
...
}

我收到一个错误:

 Type error: Type '{ placeSearchChanged: (place: any) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<PlaceSearchBar> & Readonly<{ children?: ReactNode; }> & Readonly<{}>'.
  Property 'placeSearchChanged' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<PlaceSearchBar> & Readonly<{ children?: ReactNode; }> & Readonly<{}>'.  TS2322

显然我需要在 React.Component<placeSearchChanged:function> 或类似的东西中声明类型。

我认为这很烦人,我想禁用我的 tsconfig.json 中的所有检查。

如何禁用所有检查(但仍保持安装 TypeScript,以防万一)?

这是我当前的 tsconfig.json:

 {
  "compilerOptions": {
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext",
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "noImplicitAny": false,
  },
  "include": [
    "src"
  ]
}

原文由 TIMEX 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 313
1 个回答

在 Angular 14 中,转到 tsconfig.json=> compilerOptions => strict: false

原文由 Khadija Mehmood 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题