TypeScript errors
ndias-bt opened this issue · 0 comments
ndias-bt commented
Hi, nicely written article, however running the repo as-is according to the README, and I am seeing TypeScript errors.
These might be the same type mismatch errors reported in this issue:
$ npm run start
> clean-nest@0.0.1 start
> nest start
src/frameworks/data-services/mongo/mongo-data-services.service.ts:33:55 - error TS2345: Argument of type 'Model<AuthorDocument, {}, {}, {}, any>' is not assignable to parameter of type 'Model<Author, {}, {}, {}, any>'.
Types of property 'bulkWrite' are incompatible.
Type '{ (writes: AnyBulkWriteOperation<AuthorDocument>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }' is not assignable to type '{ (writes: AnyBulkWriteOperation<Author>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }'.
Types of parameters 'writes' and 'writes' are incompatible.
Type 'AnyBulkWriteOperation<Author>[]' is not assignable to type 'AnyBulkWriteOperation<AuthorDocument>[]'.
Type 'AnyBulkWriteOperation<Author>' is not assignable to type 'AnyBulkWriteOperation<AuthorDocument>'.
Type '{ insertOne: InsertOneModel<Author>; }' is not assignable to type 'AnyBulkWriteOperation<AuthorDocument>'.
Type '{ insertOne: InsertOneModel<Author>; }' is not assignable to type '{ insertOne: InsertOneModel<AuthorDocument>; }'.
The types of 'insertOne.document' are incompatible between these types.
Type 'OptionalId<Author>' is not assignable to type 'OptionalId<AuthorDocument>'.
Type 'OptionalId<Author>' is missing the following properties from type 'Pick<AuthorDocument, keyof Author | keyof Document>': title, close, normalize, URL, and 247 more.
33 this.authors = new MongoGenericRepository<Author>(this.AuthorRepository);
~~~~~~~~~~~~~~~~~~~~~
src/frameworks/data-services/mongo/mongo-data-services.service.ts:34:51 - error TS2345: Argument of type 'Model<BookDocument, {}, {}, {}, any>' is not assignable to parameter of type 'Model<Book, {}, {}, {}, any>'.
Types of property 'bulkWrite' are incompatible.
Type '{ (writes: AnyBulkWriteOperation<BookDocument>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }' is not assignable to type '{ (writes: AnyBulkWriteOperation<Book>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }'.
Types of parameters 'writes' and 'writes' are incompatible.
Type 'AnyBulkWriteOperation<Book>[]' is not assignable to type 'AnyBulkWriteOperation<BookDocument>[]'.
Type 'AnyBulkWriteOperation<Book>' is not assignable to type 'AnyBulkWriteOperation<BookDocument>'.
Type '{ insertOne: InsertOneModel<Book>; }' is not assignable to type 'AnyBulkWriteOperation<BookDocument>'.
Type '{ insertOne: InsertOneModel<Book>; }' is not assignable to type '{ insertOne: InsertOneModel<BookDocument>; }'.
The types of 'insertOne.document' are incompatible between these types.
Type 'OptionalId<Book>' is not assignable to type 'OptionalId<BookDocument>'.
Type 'OptionalId<Book>' is missing the following properties from type 'Pick<BookDocument, "title" | "publishDate" | "close" | "normalize" | "author" | "genre" | "URL" | "alinkColor" | "all" | "anchors" | "applets" | "bgColor" | "body" | ... 244 more ... | "evaluate">': close, normalize, URL, alinkColor, and 246 more.
34 this.books = new MongoGenericRepository<Book>(this.BookRepository, [
~~~~~~~~~~~~~~~~~~~
src/frameworks/data-services/mongo/mongo-data-services.service.ts:38:53 - error TS2345: Argument of type 'Model<GenreDocument, {}, {}, {}, any>' is not assignable to parameter of type 'Model<Genre, {}, {}, {}, any>'.
Types of property 'bulkWrite' are incompatible.
Type '{ (writes: AnyBulkWriteOperation<GenreDocument>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }' is not assignable to type '{ (writes: AnyBulkWriteOperation<Genre>[], options: BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], callback: Callback<...>): void; (writes: AnyBulkWriteOperation<...>[], options?: BulkWriteOptions & MongooseBulkWriteOptions): Promise<...>; }'.
Types of parameters 'writes' and 'writes' are incompatible.
Type 'AnyBulkWriteOperation<Genre>[]' is not assignable to type 'AnyBulkWriteOperation<GenreDocument>[]'.
Type 'AnyBulkWriteOperation<Genre>' is not assignable to type 'AnyBulkWriteOperation<GenreDocument>'.
Type '{ insertOne: InsertOneModel<Genre>; }' is not assignable to type 'AnyBulkWriteOperation<GenreDocument>'.
Type '{ insertOne: InsertOneModel<Genre>; }' is not assignable to type '{ insertOne: InsertOneModel<GenreDocument>; }'.
The types of 'insertOne.document' are incompatible between these types.
Type 'OptionalId<Genre>' is not assignable to type 'OptionalId<GenreDocument>'.
Type 'OptionalId<Genre>' is missing the following properties from type 'Pick<GenreDocument, "name" | keyof Document>': title, close, normalize, URL, and 247 more.
38 this.genres = new MongoGenericRepository<Genre>(this.GenreRepository);
~~~~~~~~~~~~~~~~~~~~
src/frameworks/data-services/mongo/mongo-generic-repository.ts:18:5 - error TS2322: Type 'Promise<UnpackedIntersection<HydratedDocument<T, {}, {}>, {}>>' is not assignable to type 'Promise<T>'.
Type 'UnpackedIntersection<HydratedDocument<T, {}, {}>, {}>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'UnpackedIntersection<HydratedDocument<T, {}, {}>, {}>'.
18 return this._repository.findById(id).populate(this._populateOnFind).exec();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 error(s).