echoes-xyz / mongoose-geojson-schema

Schema definitions for GeoJSON types for use with Mongoose JS
MIT License
79 stars 25 forks source link

Conflicts on typescript compile #30

Closed vanhumbeecka closed 5 years ago

vanhumbeecka commented 5 years ago

On building my Typescript app, I noticed the following errors when running tsc:

yarn run v1.12.3
$ rm -rf dist && tsc
node_modules/@types/mongoose-geojson-schema/node_modules/@types/mongoose/index.d.ts:55:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: NativeBuffer, NativeDate, NativeError, Mongoose, CastError, ConnectionBase, Connection, Error, VirtualType, Schema, MongooseDocument, Subdocument, Array, DocumentArray, Buffer, ObjectIdConstructor, Decimal128, Embedded, Query, DocumentQuery, mquery, Aggregate, SchemaType

55 declare module "mongoose" {
   ~~~~~~~

  node_modules/@types/mongoose/index.d.ts:55:1
    55 declare module "mongoose" {
       ~~~~~~~
    Conflicts are in this file.

node_modules/@types/mongoose-geojson-schema/node_modules/@types/mongoose/index.d.ts:84:14 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'SchemaTypes' must be of type 'typeof Types', but here has type 'typeof Types'.

84   export var SchemaTypes: typeof Schema.Types;
                ~~~~~~~~~~~

node_modules/@types/mongoose-geojson-schema/node_modules/@types/mongoose/index.d.ts:1086:5 - error TS2374: Duplicate string index signature.

1086     [path: string]: SchemaTypeOpts<any> | Schema | SchemaType;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/mongoose-geojson-schema/node_modules/@types/mongoose/index.d.ts:1218:5 - error TS2374: Duplicate string index signature.

1218     [other: string]: any;
         ~~~~~~~~~~~~~~~~~~~~~

Apparently, the typings of this package goes into conflict with those of mongoose itself. How to resolve this? Is this a bug in the typings of this package? Or a misconfiguration on my part? It's not clear to me at this point.

markstos commented 5 years ago

@vanhumbeecka If you had searched the issues first for "typescript", I think you would have found that this project is not written and in TypeScript and contains no TypeScript hinting. See #24 which links to the project which contains the TypeScript definitions for the project.

I'm closing this issue because the issue is not in this project.

jessevdp commented 4 years ago

For anyone who lands here (like me). The issue seems to be an incompatible version between @types/mongoose and @types/mongoose-geojson-schema.

I just resolved a similar issue by removing the version constraints off @types/mongoose in my package.json, so the package manager could figure out the correct compatible version after a fresh install.

In package.json:

"@types/mongoose": "*",