I want to use d3-tip library to add tooltips in my charts.
Using Typescript 2.0, I added the typings for d3-tip
as follows:
npm install @types/d3-tip --save
It shows up in my package.json:
"dependencies": {
"@types/d3": "^4.7.0",
"@types/d3-tip": "^3.5.4",
}
index.d.ts
for d3-tip looks like this:
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;
}
My question is, how do I now use this/import in my code? I tried adding following:
import * as tip from 'd3-tip'; OR
import * from 'd3-tip'; OR
import { tip } from 'd3-tip';
but none of them work, and I don't get any intellisense on d3.tip()
.
How do I make it work? Thanks.
Import, which works for me:
import d3Tip from "d3-tip";
const tip = d3Tip();
However, there is small discussion about this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With