Some background info: I have small project using d3.js lib in vanilla JS and trying to remake it on TypeScript without any frameworks (React, Vue etc.).
package.json
look:
{
"dependencies": {
"d3": "^7.6.1",
"g": "^2.0.1"
},
"devDependencies": {
"@types/d3": "^7.4.0",
"@types/d3-hierarchy": "^3.1.0",
"live-server": "^1.2.2",
"typescript": "^4.8.4"
}
}
I have an error like Property 'scaleLinear' does not exist on type 'typeof d3'.ts(2339)
only with scaleLinear
, scaleBand
and histogram
. Here is code snippet:
const xScale = d3.scaleLinear()
.domain(d3.extent(dataset, metricAccessor))
.range([0, dimensions.boundedWidth]);
const binsGenerator = d3.histogram()
.domain(xScale.domain())
.value(metricAccessor)
.thresholds(10);
At the moment when I added line import * as d3 from 'd3';
into my ts-code, I had error in browser console: Uncaught ReferenceError: exports is not defined
What am I missing or doing wrong?