Type '(Document<unknown, {}, { _id: string; version: string; defaultConfThreshold: number; categories: DocumentArray<{ _id: string; name: string; color: string; }>; description?: string | null | undefined; }> & { ...; } & Required<...>)[]' is not assignable to type 'MlModel[]'.
Type 'Document<unknown, {}, { _id: string; version: string; defaultConfThreshold: number; categories: DocumentArray<{ _id: string; name: string; color: string; }>; description?: string | null | undefined; }> & { ...; } & Required<...>' is not assignable to type 'MlModel'.
The types of 'categories.push' are incompatible between these types.
Type '(...args: (AnyKeys<{ _id: string; name: string; color: string; }> & AnyObject)[]) => number' is not assignable to type '(...items: Maybe<Categories>[]) => number'.
Types of parameters 'args' and 'items' are incompatible.
Type 'Maybe<Categories>' is not assignable to type 'AnyKeys<{ _id: string; name: string; color: string; }> & AnyObject'.
Type 'null' is not assignable to type 'AnyKeys<{ _id: string; name: string; color: string; }> & AnyObject'.
Type 'null' is not assignable to type 'AnyKeys<{ _id: string; name: string; color: string; }>'.ts(2322)
In our codebase, we have the MLModel's
categories
property as an array of eitherCategories
ornull
:https://github.com/tnc-ca-geo/animl-api/blob/5522f6a70c3cc9d0eddf7a5f75b673626f53bc27/src/api/type-defs/objects/MLModel.js#L8-L14
However, in our model, we show
Categories
as being only of aCategory
:https://github.com/tnc-ca-geo/animl-api/blob/5522f6a70c3cc9d0eddf7a5f75b673626f53bc27/src/api/db/schemas/MLModel.js#L25-L37
This is causing the following TS error in following codeE:
https://github.com/tnc-ca-geo/animl-api/blob/286f7e693bd4078c709754ade5c667adbc923643/src/api/resolvers/Query.ts#L131-L137
This PR fixes that.