React-google-maps: Typings peerDependencies

Created on 2 Jan 2018  路  15Comments  路  Source: tomchentw/react-google-maps

More of a question about why the typings packages are a peer dependency?

Does this not bloat other peoples package.json if they dont use typings?

Most helpful comment

Is there a solution yet?

All 15 comments

From @mxl in https://github.com/tomchentw/react-google-maps/pull/646

This will remove UNMET PEER DEPENDENCY warnings but will not install those dependencies. So developers will have to manually navigate this package package.json and install missing definitions. I see only two ways to make package work "out of the box" for both JS and TS developers:

  • move peerDependencies to dependencies;
  • move definitions to separate package.

Thanks for reply. I think from JS developer perspective move the definitions to a separate package would be better, as then JS developers will get the bare minimum to work.

Just my two cents..

Replying to https://github.com/tomchentw/react-google-maps/pull/646#issuecomment-355295720:
@tomchentw The only disadvantage is that these definitions will be installed even if developer does not use TypeScript. I'm not sure that I understood the part about outdated dependencies.

With a current way of keeping definitions and library code in the same package I'm sure that soon we will have situation when JS code was changed but definitions were not updated because it's unlikely that JS developer making a PR will update definitions accordingly (he/she does not know TypeScript or does not know that there are definitions or does not care about them). May be we already have this situation.
By moving definitions to separate package and repository:

  1. it will allow to make definitions package dependent on specific version of react-google-maps;
  2. JS developers will not be forced to install definitions and will not see annoying peer dependency warnings;
  3. you can assign specific maintainer for definitions repository.

Instead of peerDependencies, typings should be devDependencies, optionalDependencies (or simply removed)

Anny news on this at all?

I agree with @pladaria the type peer dependencies are bloating the app and slowing down CI builds

My workaround is to pin this modules to version 9.2.1, before the peerDependency included typings and after React 16!

Please remove the peerDependencies for typings. Typings are not required to exist for any consumers of this package. They are only required for building react-google-maps, therefore they should only be listed in the devDependencies.

peerDependencies are dependencies that are strictly required for a package in order to be executed. In the case of type-definitions this is not the case and is not a pattern that I have seen in other libs.

@tomraithel @pladaria devDependencies will remove it from npm package. Definitions are required for TypeScript developers. @tomchentw could you create separate react-google-maps-types repository? I will make PR there.

Any type-checked JS or TS app dependent on react-google-maps fails to build unless you install the typings or declare a dummy module. Publishing docs say:

Do depend on the npm type declaration package if it doesn鈥檛 package its declaration files

Make sure all the declaration packages you depend on are marked appropriately in the "dependencies" section in your package.json

Consider adding a section to installation instructions, for TypeScript users, with a note what to do and why it is needed, or an "error TS2304: Cannot find name 'Calculator'" troubleshooting FAQ.

Any update on this?

I'm going through this whole TS2304: Cannot find name 'Calculator'. fiasco as we speak. Would definitely like a FAQ for this. I've installed:

  "dependencies": {
    "@types/googlemaps": "^3.30.8",
    "@types/markerclustererplus": "^2.1.33",
    "markerclustererplus": "^2.1.4",
    "react-google-maps": "^9.4.5"
  }

And still get Cannot find name 'Calculator'., TS2304: Cannot find name 'ClusterIconStyle'., and a plethora of other TS2304s.

See this #866 for discussion and solution for Cannot find name 'Calculator'

Bump, any reason these aren't just dev dependencies?

Is there a solution yet?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wayofthefuture picture wayofthefuture  路  3Comments

timkraut picture timkraut  路  3Comments

shrimpy picture shrimpy  路  3Comments

johnantoni picture johnantoni  路  3Comments

tahir-masood1 picture tahir-masood1  路  4Comments