Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between several @types package #9771

Closed
Keats opened this issue Jul 16, 2016 · 7 comments
Closed

Conflict between several @types package #9771

Keats opened this issue Jul 16, 2016 · 7 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@Keats
Copy link

Keats commented Jul 16, 2016

TypeScript Version: 2.0.0

Details
I started a new project to try TS 2.0 and the npm install @types/ way of getting typings and ran into a conflict issue.

$ npm install @types/react
$ npm install @types/react-router

React-router definition depends on @types/react.

Expected behavior:
Everything working fine

Actual behavior:

ERROR in /home/vincent/Code/mobx-test/node_modules/@types/react-router/node_modules/@types/react/index.d.ts
(7,21): error TS2300: Duplicate identifier 'React'.

ERROR in /home/vincent/Code/mobx-test/node_modules/@types/react/index.d.ts
(7,21): error TS2300: Duplicate identifier 'React'.
@mhegazy mhegazy added @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped Bug A bug in TypeScript labels Jul 17, 2016
@RyanCavanaugh RyanCavanaugh assigned ghost Jul 18, 2016
@RyanCavanaugh
Copy link
Member

@andy-ms can you take a look? We shouldn't be in this state for unversioned installs (note the installation of react in the react-router's node_modules subdir, indicating a version conflict)

@ghost
Copy link

ghost commented Jul 18, 2016

These two packages work for me when installed from scratch in either order.
React has "version": "0.14.27" and react-router has "@types/react": "0.14.*" as a dependency.

Could you please provide your npm --version? Versions of npm before version 3 did not flatten packages, so that could be the problem. If that's not it, could you tell us:

  • The version in node_modules/@types/react.package.json
  • The version and dependencies in node_modules/@types/react-router/package.json
  • The version in node_modules/@types/react-router/node_modules/@types/react/package.json

@RyanCavanaugh RyanCavanaugh assigned RyanCavanaugh and unassigned ghost Jul 18, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.0.1 milestone Jul 18, 2016
@Keats
Copy link
Author

Keats commented Jul 19, 2016

I'm indeed still using it npm 2 (2.14.4)

@Tragetaschen
Copy link

Tragetaschen commented Jul 19, 2016

I ran into this as well last week with npm 3 on Windows. I installed @types for jQuery and SignalR and this resulted in types for jQuery in node_modules of the most recent version and types for jQuery in node_modules below SignalR's folder of an older version.

Once I figured that out, I tried to update the packages and saw that the SignalR types had been updated on npm two hours earlier (but after I had installed them). It would be great if these types of dependencies on npm could be updated atomically, but I doubt that's possible.

The most annoying part was that running tsc on the command line or through awesome-typescript-loader didn't have problems with that, but Visual Studio showed these errors when building there.

@ghost
Copy link

ghost commented Aug 5, 2016

Here is a related problem and description:
File main.ts:

/// <reference path="jquery-1.10.d.ts"/>

import $ from "jquery"
import {myFunction} from "./my-module"

$('#id').click(function () {});

File my-module.ts:

/// <reference path="jquery-2.0.d.ts"/>

import $ from "jquery"

export function myFunction() {}

Files jquery-1.10.d.ts and jquery-2.0.d.ts are files with the same content, just for testing, but it can be slightly different for different version of the jQuery, and theirs content is latest version of the jquery.d.ts from the DefinitelyTyped (https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/jquery/jquery.d.ts):

 md5sum jquery-1.10.d.ts jquery-2.0.d.ts
7ef0067d2faf006343aa95157f492867  jquery-1.10.d.ts
7ef0067d2faf006343aa95157f492867  jquery-2.0.d.ts

Now try to compile the main.ts with:

tsc --moduleResolution node -t ES5 main.ts

Expected result: no errors

Actual result:

jquery-2.0.d.ts(615,5): error TS2374: Duplicate string index signature.
jquery-2.0.d.ts(2844,5): error TS2374: Duplicate string index signature.
jquery-2.0.d.ts(2845,5): error TS2375: Duplicate number index signature.
jquery-2.0.d.ts(3218,5): error TS2300: Duplicate identifier 'export='.
my-module.ts(3,8): error TS1192: Module '"jquery"' has no default export.
jquery-1.10.d.ts(3218,5): error TS2300: Duplicate identifier 'export='.
main.ts(3,8): error TS1192: Module '"jquery"' has no default export.

I.e. you see batch of errors. It seems like tsc does not allow use different version of the .d.ts files with the same declarations for the included module/file. However I think it should not produce errors because the included module can use different version of the same library as shown above with file names - jquery-1.10.d.ts and jquery-2.0.d.ts.

tsc version:

tsc --version
Version 2.1.0-dev.20160805

@mhegazy
Copy link
Contributor

mhegazy commented Aug 16, 2016

The original issue has been fixed, but there are new issues, i have a fix queued up in DefinitelyTyped/DefinitelyTyped#10663

@mhegazy mhegazy assigned mhegazy and unassigned RyanCavanaugh Aug 16, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Aug 24, 2016

should be fixed in @types/react-router@2.0.33

@mhegazy mhegazy closed this as completed Aug 24, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 24, 2016
RyanCavanaugh added a commit to RyanCavanaugh/TypeScript that referenced this issue Aug 26, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

4 participants