【发布时间】:2017-09-06 02:53:15
【问题描述】:
我想使用d3-tip 库在我的图表中添加工具提示。
使用 Typescript 2.0,我为d3-tip 添加了如下类型:
npm install @types/d3-tip --save
它显示在我的 package.json 中:
"dependencies": {
"@types/d3": "^4.7.0",
"@types/d3-tip": "^3.5.4",
}
d3-tip 的index.d.ts 如下所示:
import {Primitive} from "d3";
declare module "d3" {
type TooltipDirection = ("n" | "s" | "e" | "w" | "nw" | "ne" | "sw" | "se");
interface Tooltip {
hide(): Tooltip;
show(): Tooltip;
destroy(): Tooltip;
....
}
export function tip(): Tooltip;
}
我的问题是,我现在如何在我的代码中使用这个/导入?我尝试添加以下内容:
import * as tip from 'd3-tip'; OR
import * from 'd3-tip'; OR
import { tip } from 'd3-tip';
但它们都不起作用,而且我在 d3.tip() 上没有任何智能感知。
如何让它发挥作用?谢谢。
【问题讨论】:
-
嗨,你有什么发现吗?
-
对不起,没有智能感知就必须使用它。
-
你的意思是它只是通过忽略警告来工作?编译了吗?
标签: typescript typescript-typings typescript2.0 typing definitelytyped