React-popper: remove @types/react from dependencies

Created on 6 Nov 2018  路  9Comments  路  Source: popperjs/react-popper

From #234, I think library shouldn't include types of other dependencies. If types has to be in dependencies, it has to be in react project itself, so other dependencies those depend on it, don't have to make the redundancy.

I have tons of examples
react-dropzone: https://github.com/react-dropzone/react-dropzone/blob/master/package.json
react-datepicker: https://github.com/Hacker0x01/react-datepicker/blob/master/package.json
reactstrap: https://github.com/reactstrap/reactstrap/blob/master/package.json

But if it's @type/react-popper, then yeah, it'd make a bit sense.

TypeScript Madness

Most helpful comment

@rogierschouten no, that is an absurd move because every application has to declare @types/react as dependencies regardless it uses typescript or not

I have 2 suggestions

  1. (Recommended) In this project, just declare @types/react in devDependencies (or completely remove from everywhere)
    so applications those use typescript and this library, they has to add @types/react to their own package.json
  2. In this project, declare in dependencies with "*" as version.

All 9 comments

react-popper types require React types, so it's correct to have them in the dependencies list.

@FezVrasta what is the solution? I always have to manually remove @types/react from node_modules/react-popper otherwise it conflicts with @types/react installed in project dependencies. It causes very ugly errors like:

ERROR in [at-loader] ./node_modules/@types/react/index.d.ts:2305:19 
    TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement<any>' and 'ReactElement<any>'.
  Named property 'type' of types 'ReactElement<any>' and 'ReactElement<any>' are not identical.

as @1pete mentions, it can be solved (as examples).

Next thing is types (@types/react) are in dependencies and devDependencies ... twice

I'm sorry guys, I don't know, I just can't stand TypeScript problems anymore. It's always a problem with this thing. Why don't you guys use Flow? It just works 馃槱

Please feel free to discuss here with each others and decide about a solution, I don't know anything about TS and the more issues I see about it the less I want to know.

I'll reopen this issue until you guys find a solution. Feel free to send PRs to show what you'd like to change but please include extensive tests to make sure it really works, because every time someone merges a PR about TypeScript a bunch of people comes here complaining that everything is broken.

Sorry for my tone, I don't want to be rude, but this story has going on for so long that I got sick of it, next step will be to get rid of the types all together and just ship Flow.

What about moving TypeScript definitions to https://github.com/DefinitelyTyped/DefinitelyTyped and that is all... For those who want it, install @types/react-popper....

Yes that'd be a good idea but then I will not even try to maintain them anymore.

Honestly I thought it would be easy to ship those types with the library, with Popper.js (which is not typed) I just added a popper.js.flow file with the types and it just works, I thought it would have been the same with TS here...

@FezVrasta the real solution is to make @types/react both a peerDependency and a devDependency. The peerDependency should preferably have a "*" version or a version range.

@rogierschouten no, that is an absurd move because every application has to declare @types/react as dependencies regardless it uses typescript or not

I have 2 suggestions

  1. (Recommended) In this project, just declare @types/react in devDependencies (or completely remove from everywhere)
    so applications those use typescript and this library, they has to add @types/react to their own package.json
  2. In this project, declare in dependencies with "*" as version.

I'm sorry guys, I don't know, I just can't stand TypeScript problems anymore. It's always a problem with this thing. Why don't you guys use Flow? It just works :weary:

my thoughts on that exactly! If only people could see that Clojure just works and used it instead of JavaScript ;(

I think @1pete's suggestion about installing it as a devDependency is spot on, this seems to be what other libs are doing without causing problems.

For those of us using yarn you can use selective dependency resolutions to get around this, just add the following to your package.json:

  "resolutions": {
    "react-popper/@types/react": "16.4.1"
  },

Note: Use the version of @types/react you're using otherwise

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sajcics picture sajcics  路  3Comments

nstepien picture nstepien  路  5Comments

clintharris picture clintharris  路  6Comments

Argonanth picture Argonanth  路  4Comments

websitesca picture websitesca  路  5Comments