[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的主要内容,如果未能解决你的问题,请参考以下文章

Vue 3 @typescript-eslint/no-unsafe-member-access

[TypeScript@2.5] Omit catch error block if not needed

带有 parserOptions 和排除的 Catch-22

类型“Promise<void>”上不存在属性“catch”

Nodejs/NestJS ExceptionFilter Catch 方法的 Jest 单元测试

Promise.catch() 不会在 AngularJS 单元测试中捕获异常