typescript - 始终指定变量类型
问题描述
我正在使用 TypeScript、ESLint 和 @typescript-eslint。我想始终指定变量类型并在我不指定变量类型时出现错误:
const myVariable = 1; // -> error
const myVaribale: number = 1 // -> ok
我在互联网上找不到任何东西。
解决方案
为我工作
添加到 .eslint.js
'@typescript-eslint/typedef': [
'error',
{
arrayDestructuring: true,
arrowCallSignature: true,
arrowParameter: true,
callSignature: true,
memberVariableDeclaration: true,
parameter: true,
propertyDeclaration: true,
objectDestructuring: true,
variableDeclaration: true,
variableDeclarationIgnoreFunction: true,
},
],
'@typescript-eslint/no-inferrable-types': 0,
推荐阅读
- django - django rest框架不显示响应数据
- mysql - 如何将其转换为 DATETIME SQL?
- python - 没有收到回波警告导致我的 HR-SC04 超声波模块(距离传感器)导致输出错误
- tensorflow - 我在自定义数据集上训练了 ssd mobilenet v1,在 jetson 中运行的尺寸减小问题
- javascript - 尝试使用 webpack 构建捆绑包时出错
- javascript - 我如何从存储在本地存储中的令牌中访问数据以做出反应
- android - Razorpay 结帐表格卡在 webview 中加载
- mysql - SQL 中有两个“加入”的不需要的结果
- extjs - 如何更新 extJs 中的存储(出现 404 错误)?
- database - 估计 Google BigTable 中的数据大小