kiran goud
kiran goud

Reputation: 843

Module '"../node_modules/@types/d3"' has no exported member 'event'

I have 2 pbiviz projects with all similar packages versions.

"dependencies": {
   "@babel/runtime": "7.6.0",
   "@babel/runtime-corejs2": "7.6.0",
   "@types/d3": "5.7.2",
   "d3": "5.12.0",
   "powerbi-visuals-utils-dataviewutils": "2.2.1",
   "powerbi-visuals-api": "~2.6.1",
   "core-js": "3.2.1"
}

The old project imports event perfectly from d3. But the new project is showing this error.

Module '"../node_modules/@types/d3"' has no exported member 'event'.ts(2305)

Module '"../node_modules/@types/d3"' has no exported member 'event'.

After unsuccessful at searching for solution and other attempts like deleting and running npm i, I just copy pasted the 'node_modules/@types' folder from old project to new project and it worked.

If anyone know what caused this problem and a proper solution, please share.

Upvotes: 2

Views: 2561

Answers (2)

kiran goud
kiran goud

Reputation: 843

I just updated both D3js and Types,

npm i d3@latest @types/d3@latest

This solved the issue. Now event is the first parameter of the event listener callback function.

Upvotes: 0

ryanharrigan
ryanharrigan

Reputation: 31

event is part of d3-selection and only exported in the v1 of @types/d3-selection. Running yarn list/npm list, you'll see that "@types/d3": "5.7.4" dependency for d3-selection is @types/d3-selection@*, which is actually defaulted to v2.

screenshot of @types/d3 dependency list

Solution is to include "@types/d3-selection": "^1.0.0" in dependencies

Upvotes: 2

Related Questions