[英]How to config stricter type checks in TypeScript?
I want to have stricter code checks and I don't want to be allowed to have any implicit 'any' types.我想要进行更严格的代码检查,并且我不想被允许拥有任何隐式的“任何”类型。 Therefore I enabled
"strict": true
因此我启用了
"strict": true
tsconfig.json tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"strict": true
},
"include": ["./"]
}
If I write this function:如果我写这个 function:
const testing = () => console.log("test");
VSCode auto infers the returning type by it's usage: VSCode 自动通过它的用法推断返回类型:
const testing: () => void
Is there any way I can make this stricter and not allow VSCode to auto infer?有什么办法可以让这个更严格并且不允许 VSCode 自动推断?
thanks谢谢
emmm, in this case, you'd ll better use eslint intead of hacking ts, see here: emmm,在这种情况下,您最好使用 eslint 而不是 hacking ts,请参见此处:
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.