首页 经验

typescript noImplicitAny

时间: 2024-09-19 23:52:50

(部分内容来自网络,其真实性存疑,为了避免对您造成误导,请谨慎甄别。)


No Implicit Any - noImplicitAny

In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type.


This can cause some errors to be missed, for example:


function fn(s) {

  // No error?

  console.log(s.subtr(3));

}

fn(42);


Turning on noImplicitAny however TypeScript will issue an error whenever it would have inferred any:


function fn(s) {

  //Parameter 's' implicitly has an 'any' type.

  console.log(s.subtr(3));

}


上一个 typescript Type Assertions 文章列表 下一个 Latex 希腊字母表

最新

工具

© 2019-至今 适观科技

沪ICP备17002269号