Definitelytyped: [d3] Module 'd3-scale' has already exported a member named 'interpolateCool'. Consider explicitly re-exporting to resolve the ambiguity.

Created on 27 Mar 2018  ·  3Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

  • I tried using the @types/d3 package and had problems.
  • Authors: @tomwanzek @gustavderdrache @borisyankov

I am trying to update from d3 v4.x to 5.0, with the following dependencies:

"d3": "5.0.0",
"@types/d3": "5.0.0",

When I compile the app I see:

ERROR in node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateCool'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateCubehelixDefault'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateInferno'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateMagma'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolatePlasma'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateRainbow'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateViridis'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'interpolateWarm'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@types/d3/index.d.ts(37,1): error TS2308: Module 'd3-scale' has already exported a member named 'schemeCategory10'. Consider explicitly re-exporting to resolve the ambiguity.

If it makes any difference, my app is compiled using angular-cli (webpack) and it references d3 in the types array in tsconfig.app.json.

I'm not sure if this is specific to my setup in some way, or if it's a bug - so would appreciate help from anyone who knows more about this.

Most helpful comment

Thanks @tomwanzek - yes it seemed to be some kind of strange version conflict with the dependencies referenced in my yarn.lock file.

Originally, I just updated the version numbers in package.json and ran yarn install, which for whatever reason resulted in the errors above.

However, removing d3 and the type definitions first, then adding the packages back in at their latest versions seems to solve it. The following did the trick:

yarn remove @d3
yarn remove @types/d3
yarn add @d3
yarn add @types/d3 --dev

All 3 comments

@matt-senseye I'm not sure why you would add d3 to the types array in tsconfig.app.json, there should be no need to do so. Standard TS modules/typings resolution should address everything.

Do you have a package-lock.json or yarn equivalent to check the dependencies which were installed for d3 and @types/d3? There seems to be a version conflict between d3-scale and d3-scale-chromatic. The errors you listed are all former features of [email protected], which as of d3-scale@2 have been refactored to d3-scale-chromatic. So, your install should have an implied dependency on d3-scale@2 .

Thanks @tomwanzek - yes it seemed to be some kind of strange version conflict with the dependencies referenced in my yarn.lock file.

Originally, I just updated the version numbers in package.json and ran yarn install, which for whatever reason resulted in the errors above.

However, removing d3 and the type definitions first, then adding the packages back in at their latest versions seems to solve it. The following did the trick:

yarn remove @d3
yarn remove @types/d3
yarn add @d3
yarn add @types/d3 --dev

I have a very similar error, but

npm remove --save-exact d3
npm remove --save-exact @types/d3
npm install --save-exact d3
npm install --save-exact -D @types/d3

does not solve it.

When I navigate to the types themselves, I can see that d3-scale and d3-scale-chromatic sometimes export the same functions:

Screen Shot 2019-05-06 at 13 25 10

Is this normal? Should I not install d3 but each separate packages instead?

Was this page helpful?
0 / 5 - 0 ratings