this keyword for function parameter

走远了吗. 提交于 2019-12-01 08:22:01

You can (since version 2.0 of typescript) specify what is the this you're expecting when a function is invoked.

As described in Specifying the type of this for functions:

Following up on specifying the type of this in a class or an interface, functions and methods can now declare the type of this they expect.

By default the type of this inside a function is any. Starting with TypeScript 2.0, you can provide an explicit this parameter. this parameters are fake parameters that come first in the parameter list of a function

Notice that this won't get translated into js, so it's not a real argument in the function.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!