Skip to content

Failing on compilation due to TS2403: Subsequent variable declarations must have the same type. #204

Description

@NickGlenn
  • Rollup Plugin Name: typescript
  • Rollup Plugin Version: 3.0.0
  • Rollup Version: 1.30.1, 1.27.14
  • Operating System (or Browser): Windows, OSX
  • Node Version: 8.10.0 (Win), 12.15.0 (Win), 12.15.0 (OSX)

How Do We Reproduce?

Repl.it Project Replicating the Issue

I've seen this occur on a couple different libraries know, but the most notable one is react-router-dom. Set up a React project and install react-router-dom along with the types, @types/react-router-dom.

Expected Behavior

Ideally it should compile unless there's actual user error. Using the exact same project but with the old rollup-plugin-typescript module works flawlessly.

Actual Behavior

Build fails due to TS2403: Subsequent variable declarations must have the same type. Variable 'History' ....

src/index.tsx → dist/bundle.js...
[!] (plugin typescript) Error: @rollup/plugin-typescript TS2403: Subsequent variable declarations must have the same type.  Variable 'History' must be of type 'typeof import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index")', but here has type '{ new (): import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index"); prototype: import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index"); }'.
node_modules/typescript/lib/lib.dom.d.ts (9211:13)

9211 declare var History: {
                 ~~~~~~~

  node_modules/@types/history/index.d.ts:6:1
    6 export as namespace History;
      ~~~~~~
    'History' was also declared here.

Error: @rollup/plugin-typescript TS2403: Subsequent variable declarations must have thesame type.  Variable 'History' must be of type 'typeof import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index")', but here has type '{ new (): import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index"); prototype: import("/home/runner/PeskyBigheartedForms/node_modules/@types/history/index"); }'.
    at error (/home/runner/PeskyBigheartedForms/node_modules/rollup/dist/rollup.js:5365:30)
    at throwPluginError (/home/runner/PeskyBigheartedForms/node_modules/rollup/dist/rollup.js:11725:12)
    at Object.error (/home/runner/PeskyBigheartedForms/node_modules/rollup/dist/rollup.js:12694:24)
    at diagnostics.filter.forEach (/home/runner/PeskyBigheartedForms/node_modules/@rollup/plugin-typescript/dist/index.js:27:21)
    at Array.forEach (<anonymous>)
    at emitDiagnostics (/home/runner/PeskyBigheartedForms/node_modules/@rollup/plugin-typescript/dist/index.js:22:10)
    at Object.generateBundle (/home/runner/PeskyBigheartedForms/node_modules/@rollup/plugin-typescript/dist/index.js:474:13)
    at Promise.resolve.then (/home/runner/PeskyBigheartedForms/node_modules/rollup/dist/rollup.js:12899:25)
    at process._tickCallback (internal/process/next_tick.js:68:7)

exit status 1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions