不幸地
@types/rickshaw
似乎是空的,所以我必须制作自己的声明文件。这是我当前的一个:
declare module 'rickshaw' {
export class Graph {
constructor(obj: any);
render: any;
}
}
这让我可以使用这些方法
render
并创建一个新实例。但现在我想声明一个来自Rickhaw的深度嵌套方法。我当前的声明不允许我使用它,错误如下:
Rickshaw.Graph.Axis.Time({graph: newGraph})
(25,41): Property 'Axis' does not exist on type 'typeof Graph'.
我检查了该方法的源代码,结果如下
Rickshaw.namespace('Rickshaw.Graph.Axis.Time');
Rickshaw.Graph.Axis.Time = function(args) {
//...
}
如何申报
Rickshaw.Graph.Axis.Time
?
编辑:这是我的新声明文件。我现在遇到了
'new' expression, whose target lacks a constructor signature implicitly has an any type
interface TimeArgs {
graph: typeof Graph;
ticksTreatment: string;
}
interface AxisInterface {
Time: (args: TimeArgs) => void;
}
export class Graph {
constructor(obj: any);
render: any;
static Axis: AxisInterface;
}
我试图通过陈述
tyepof Graph
,因为
graph
中的参数
Time
是的实例
new Rickshaw.Graph
对象,但我仍然得到错误。