typescript中构造函数类型引用

2021-02-24  本文已影响0人  NanaCti

报错内容

This expression is not constructable.
Type 'Point' has no construct signatures.

构造函数的类型无法直接引用

class Point {
  constructor(lng: number, lat: number);
  lng: number;
  lat: number;
  equals(other: Point): boolean;
}

// 错误写法
declare interface BMapGL {
  Point: Point ;
}

// 正确写法
declare interface BMapGL {
  Point: { new (lng: number, lat: number): Point }; 
}
上一篇 下一篇

猜你喜欢

热点阅读