[英]TypeScript error TS2345 when rejecting a Promise with an error
[英]TS2345 error, but the arguments should be ok?
所以我有這個錯誤:
TS2345: Argument of type '(bounds: any, fill: any, stroke: any, strokewidth: any) => mxShape' is not assignable to parameter of type 'new (...args: any) => mxShape'.
Type '(bounds: any, fill: any, stroke: any, strokewidth: any) => mxShape' provides no match for the signature 'new (...args: any): mxShape'.
據我了解, new (...args: any): mxShape
對於給定的情況應該足夠了,但是 Typescript 說,它不適合它。 為什么?
這就是我的 MxHeaderShape 的構建方式:
function MxHeaderFooterShape(bounds, fill, stroke, strokewidth) : mxShape{
let val = mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
return val;
}
您似乎想創建一個擴展MxHeaderFooterShape
的mxShape
。 假設您正在使用typed-mxgraph ,您可以使用這種方式
import mx from './mxgraph'; // mxGraphExportObject returned by the mxgraph factory function
import { mxRectangle } from 'mxgraph';
class CustomMxShape extends mx.mxShape {
constructor(bounds: mxRectangle, fill: string, stroke: string, strokewidth?: number) {
super(bounds, fill, stroke, strokewidth);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.