I\’m in the deployment section. Was going to run my build script and I didn not get the same error about mongoose/ typegoose but another . I have the same app as you do however without even thinking it i have built both my frontend and backend with vite.
Here\’s my terminal error:
[apcode language=\”bash\”]
node_modules/@typegoose/typegoose/lib/typeguards.d.ts:14:130 - error TS2677: A type predicate\'s type must be assignable to its parameter\'s type. Type \'Array<DocumentType<NonNullable<T>>>\' is not assignable to type \'Array<Ref<T, S>>\'. Types of property \'toObject\' are incompatible. Type \'{ (options?: ToObjectOptions<DocumentType<NonNullable<T>>> | undefined): any; <T>(options?: ToObjectOptions<T> | undefined): T; }\' is not assignable to type \'{ (options?: ToObjectOptions<Ref<T, S>> | undefined): any; <T>(options?: ToObjectOptions<T> | undefined): T; }\'. Types of parameters \'options\' and \'options\' are incompatible. Type \'ToObjectOptions<Ref<T, S>> | undefined\' is not assignable to type \'ToObjectOptions<DocumentType<NonNullable<T>>> | undefined\'. Type \'ToObjectOptions<Ref<T, S>>\' is not assignable to type \'ToObjectOptions<DocumentType<NonNullable<T>>>\'. Types of property \'transform\' are incompatible. Type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\' is not assignable to type \'boolean | ((doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any) | undefined\'. Type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\' is not assignable to type \'boolean | ((doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any) | undefined\'. Type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\' is not assignable to type \'(doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any\'. Types of parameters \'options\' and \'options\' are incompatible. Type \'ToObjectOptions<DocumentType<NonNullable<T>>>\' is not assignable to type \'ToObjectOptions<Ref<T, S>>\'. Types of property \'transform\' are incompatible. Type \'boolean | ((doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any) | undefined\' is not assignable to type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\'. Type \'(doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any\' is not assignable to type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\'. Type \'(doc: DocumentType<NonNullable<T>>, ret: Record<string, any>, options: ToObjectOptions<DocumentType<NonNullable<T>>>) => any\' is not assignable to type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\'. Types of parameters \'doc\' and \'doc\' are incompatible. Type \'Ref<T, S>\' is not assignable to type \'DocumentType<NonNullable<T>>\'. Type \'S\' is not assignable to type \'DocumentType<NonNullable<T>>\'. 14 export declare function isDocumentArray<T, S extends RefType>(docs: mongoose.Types.Array<Ref<T, S>> | null | undefined): docs is mongoose.Types.Array<DocumentType<NonNullable<T>>>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ node_modules/@typegoose/typegoose/lib/typeguards.d.ts:34:155 - error TS2677: A type predicate\'s type must be assignable to its parameter\'s type. Type \'Array<NonNullable<S>>\' is not assignable to type \'Array<Ref<T, S>>\'. Types of property \'toObject\' are incompatible. Type \'{ (options?: ToObjectOptions<NonNullable<S>> | undefined): any; <T>(options?: ToObjectOptions<T> | undefined): T; }\' is not assignable to type \'{ (options?: ToObjectOptions<Ref<T, S>> | undefined): any; <T>(options?: ToObjectOptions<T> | undefined): T; }\'. Types of parameters \'options\' and \'options\' are incompatible. Type \'ToObjectOptions<Ref<T, S>> | undefined\' is not assignable to type \'ToObjectOptions<NonNullable<S>> | undefined\'. Type \'ToObjectOptions<Ref<T, S>>\' is not assignable to type \'ToObjectOptions<NonNullable<S>>\'. Types of property \'transform\' are incompatible. Type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\' is not assignable to type \'boolean | ((doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any) | undefined\'. Type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\' is not assignable to type \'boolean | ((doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any) | undefined\'. Type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\' is not assignable to type \'(doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any\'. Types of parameters \'options\' and \'options\' are incompatible. Type \'ToObjectOptions<NonNullable<S>>\' is not assignable to type \'ToObjectOptions<Ref<T, S>>\'. Types of property \'transform\' are incompatible. Type \'boolean | ((doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any) | undefined\' is not assignable to type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\'. Type \'(doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any\' is not assignable to type \'boolean | ((doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any) | undefined\'. Type \'(doc: NonNullable<S>, ret: Record<string, any>, options: ToObjectOptions<NonNullable<S>>) => any\' is not assignable to type \'(doc: Ref<T, S>, ret: Record<string, any>, options: ToObjectOptions<Ref<T, S>>) => any\'. Types of parameters \'doc\' and \'doc\' are incompatible. Type \'Ref<T, S>\' is not assignable to type \'NonNullable<S>\'. Type \'S\' is not assignable to type \'NonNullable<S>\'. 34 export declare function isRefTypeArray<T, S extends RefType>(docs: mongoose.Types.Array<Ref<T, S>> | null | undefined, refType: AllowedRefTypes): docs is mongoose.Types.Array<NonNullable<S>>;
[/apcode]
Any idea how to fix it?
Bassir Answered question November 21, 2023
hello there,
for this error:
error TS2677: A type predicate\'s type must be assignable to its parameter\'s type.
it means you have defined a wrong data type for a field in the model.
Bassir Answered question November 21, 2023