Search code examples
typescriptd3.jstypesbabeljstypescript-typings

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.


Solution

  • 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.