【问题标题】:'this' implicitly has type 'any' [duplicate]'this' 隐含类型为'any' [重复]
【发布时间】:2020-10-16 02:21:01
【问题描述】:
interface ob {
  [key: string]: string
}

function DrawFillSVG(options: ob) {
  this.options = extend({}, this.options);
  extend(this.options, options);
  this._init();
}

错误提示:

 TS2683: 'this' implicitly has type 'any' because it does not have a type annotation

但我不清楚如何去做,任何帮助都会得到帮助

【问题讨论】:

  • 改用class DrawFillSVG
  • 显示整个文件
  • 什么是选项??

标签: javascript typescript prototype


【解决方案1】:

函数this类型注解如下:

function DrawFillSVG(this: whateverType, options: ob) {
  this.options = extend({}, this.options);
  extend(this.options, options);
  this._init();

【讨论】:

    猜你喜欢
    • 2020-12-17
    • 2021-12-11
    • 2017-06-16
    • 2020-09-25
    • 2019-08-04
    • 2021-09-27
    • 2019-12-21
    • 2019-06-08
    • 2018-10-29
    相关资源
    最近更新 更多