简体   繁体   English

在 Typescript 中,有没有办法使 function 参数强制输入

[英]In Typescript, is there a way to make function parameters typing mandatory

I'm working on a big project with JS and TS files and sometimes there are no types on Typescript functions.我正在处理一个带有 JS 和 TS 文件的大型项目,有时 Typescript 函数上没有类型。

Since we want to use typescript to type things I would like to have a way to make function parameters mandatory with typescript CLI or ESLint, is this possible?由于我们想使用 typescript 来输入内容,我想有一种方法使 function 参数强制使用 typescript CLI 或 ESLint,这可能吗?

Did not find anything on it.没有找到任何东西。

TSConfig option noImplicitAny will ensure that parameters are specified and not assumed to be any . TSConfig 选项noImplicitAny将确保指定参数并且不假定为any

noImplicitReturns will also help for return types. noImplicitReturns也将有助于返回类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM