“any” in Typescript

后端 未结 4 1565
不知归路
不知归路 2021-01-20 15:10

I am beginner in typescript. I have a doubt in usage of \"any\" type.

Using \"any\" is basically opting out type checking if I am right. For example

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 16:08

    any opts out type checking as you have said. The second description you have came up with (without any) will compile too. But it is not valid(*) when you use linting like tslint.

    (*) By not valid, I meant the IDE you use will pop up an alert. But, to the bottom line; any valid Javascript code is also valid for Typescript on the grounds of compiling.

提交回复
热议问题