[TypeScript] Catch unsafe use of "this" in TypeScript functions

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TypeScript] Catch unsafe use of "this" in TypeScript functions相关的知识,希望对你有一定的参考价值。

this is probably the most tricky thing to use in javascript and therefore TypeScript. Fortunately there is a TypeScript compiler flag noImplicit this that can help catch unsafe usages so beginners don‘t get caught off guard.

 

// tsconfig.json

{
  "compilerOptions": {
    "noImplicitThis": true,

...
}

 

以上是关于[TypeScript] Catch unsafe use of "this" in TypeScript functions的主要内容,如果未能解决你的问题,请参考以下文章