(like any other) is just a type statement that works during development / compilation and has no side effects at runtime, because it's just a Typescript thing. This can be useful if something related to this
for example, this[whatever]
throws a TS error, therefore whatever
not defined inside this
type TS. Thus, this error can be suppressed using (this as any)[whatever]
In addition (this as any)
is equivalent to (<any> this)
Note to mention: --suppressImplicitAnyIndexErrors
as a compiler option suppresses such possible errors.
source share