typescript - 如何在 TypeScript 中配置更严格的类型检查?
问题描述
我想要进行更严格的代码检查,并且我不想被允许拥有任何隐式的“任何”类型。因此我启用了"strict": true
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"strict": true
},
"include": ["./"]
}
如果我写这个函数:
const testing = () => console.log("test");
VSCode 自动通过它的用法推断返回类型:
const testing: () => void
有什么办法可以让这个更严格并且不允许 VSCode 自动推断?
谢谢
解决方案
emmm,在这种情况下,您最好使用 eslint 而不是 hacking ts,请参见此处:
推荐阅读
- influxdb - 从 influxdb 查询一个月内服务器的工作和非工作时间平均/百分比利用率
- android - 应用更新后未收到设备 ID - FCM Firebase
- angular - 列表数组转换为对象
- java - Spring xml文件引用服务问题
- php - 避免 $ 在 php 上签名以从 json 打印数组值
- intellij-idea - 我无法在 IntelliJ Idea 中设置 Spring Social ShowCase 项目
- linux - 同时使用 wget 进行多个下载
- ubuntu-18.04 - 如何从快照应用程序中打开终端?
- python - Python编程_,看不懂这是什么代码
- android - 如何使用 android studio 和 android-box 调试 android TV 应用程序?