I am currently working on a project that involves TypeScript and d3. I have already installed 'd3' and '@types/d3', and my use of d3 looks like this:
import * as d3 from 'd3';
const x = d3.scaleLinear ...
Everything was going smoothly until I needed to use d3.scaleSymlog
, which is not included in the current '@types/d3-selection'.
In an attempt to solve this issue, I decided to augment the 'd3-selection' module:
declare module 'd3-selection' {
export function scaleSymlog(...);
}
However, after making this change, none of the symbols from 'd3-selection' or any other d3 submodules used in my code could be found:
Property 'mouse' does not exist on type 'typeof import("<project>/frontend/node_modules/@types/d3/index")'.
According to the TypeScript documentation:
You can’t declare new top-level declarations in the augmentation – just patches to existing declarations.
So, I am left wondering how I can properly declare and use scaleSymlog
.