notiz-dev / nestjs-prisma

Easy Prisma support for your NestJS application
https://nestjs-prisma.dev
MIT License
572 stars 49 forks source link

When i run NestJS it show prisma type error #103

Open PromproEXE opened 1 day ago

PromproEXE commented 1 day ago

Hello i facing some strange error with prisma client extension when i run yarn run start:dev in my terminal show this error

https://docs.google.com/document/d/1jBvI-jnSfBvERhZ_JrOQv2KctHg4Y1UF8y95bzBwRDs/edit?usp=sharing

i run npx prisma generate, npx prisma migrate dev but this error does not go away

this is my prisma.extension.ts

import { PrismaClient } from '@prisma/client';

export const extendedPrismaClient = new PrismaClient().$extends({
    result: {
        user: {
            fullName: {
                needs: { firstName: true, lastName: true },
                compute(user) {
                    return `${user.firstName} ${user.lastName}`.trim();
                },
            },
        },
        customerRevision: {
            fullName: {
                needs: { firstName: true, lastName: true },
                compute(customer) {
                    return `${customer.firstName} ${customer.lastName}`.trim();
                },
            },
        },
        supplier: {
            fullName: {
                needs: { firstName: true, lastName: true },
                compute(supplier) {
                    return `${supplier.firstName} ${supplier.lastName}`.trim();
                },
            },
        },
    },
});

export type ExtendedPrismaClient = typeof extendedPrismaClient;

this is my code where the problem is

import { Inject, Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { CustomPrismaService } from 'nestjs-prisma';
import type { ExtendedPrismaClient } from 'src/common/bin/prisma.extension';

@Injectable()
export class WorkOrderItemRepository {
    constructor(
        @Inject('PrismaService')
        private readonly prisma: CustomPrismaService<ExtendedPrismaClient>,
    ) {}
    private WorkOrderItem = this.prisma.client.workOrderItem;

    async delete(
        id: number,
        opt: Omit<Prisma.WorkOrderItemDeleteArgs, 'where'> = {},
    ) {
        const isExist = await this.isExist(id);
        if (!isExist) return null;

        const workOrderItem = this.WorkOrderItem.delete({
            ...opt,
            where: { id },
        });

        return workOrderItem;
    }
}
marcjulian commented 1 day ago

Hi can you post the error into this issue?

PromproEXE commented 1 day ago

@marcjulian

error TS2345: Argument of type '{ where: { id: number; }; select?: Prisma.WorkOrderItemSelect<DefaultArgs>; include?: Prisma.WorkOrderItemInclude<DefaultArgs>; }' is not assignable to parameter of type '{ select?: { id?: Exact<boolean, boolean>; createdAt?: Exact<boolean, boolean>; updatedAt?: Exact<boolean, boolean>; name?: Exact<boolean, boolean>; workOrder?: Exact<...>; ... 7 more ...; unitMultiplier?: Exact<...>; }; include?: { ...; }; where: Exact<...>; }'.
  The types of 'select.workOrder' are incompatible between these types.
    Type 'boolean | WorkOrderDefaultArgs<DefaultArgs>' is not assignable to type 'Exact<boolean | WorkOrderDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>, boolean | WorkOrderDef...'.
      Type 'WorkOrderDefaultArgs<DefaultArgs>' is not assignable to type 'Exact<boolean | WorkOrderDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>, boolean | WorkOrderDef...'.
        Type 'WorkOrderDefaultArgs<DefaultArgs>' is not assignable to type 'WorkOrderDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
          The types of 'select.project' are incompatible between these types.
            Type 'boolean | ProjectDefaultArgs<DefaultArgs>' is not assignable to type 'boolean | ProjectDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
              Type 'ProjectDefaultArgs<DefaultArgs>' is not assignable to type 'boolean | ProjectDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                Type 'ProjectDefaultArgs<DefaultArgs>' is not assignable to type 'ProjectDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                  The types of 'select.invoices' are incompatible between these types.
                    Type 'boolean | Project$invoicesArgs<DefaultArgs>' is not assignable to type 'boolean | Project$invoicesArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                      Type 'Project$invoicesArgs<DefaultArgs>' is not assignable to type 'boolean | Project$invoicesArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                        Type 'Project$invoicesArgs<DefaultArgs>' is not assignable to type 'Project$invoicesArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                          The types of 'select.project' are incompatible between these types.
                            Type 'boolean | Invoice$projectArgs<DefaultArgs>' is not assignable to type 'boolean | Invoice$projectArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                              Type 'Invoice$projectArgs<DefaultArgs>' is not assignable to type 'boolean | Invoice$projectArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                Type 'Invoice$projectArgs<DefaultArgs>' is not assignable to type 'Invoice$projectArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                  The types of 'include.customer' are incompatible between these types.
                                    Type 'boolean | CustomerRevisionDefaultArgs<DefaultArgs>' is not assignable to type 'boolean | CustomerRevisionDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                      Type 'CustomerRevisionDefaultArgs<DefaultArgs>' is not assignable to type 'boolean | CustomerRevisionDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                        Type 'CustomerRevisionDefaultArgs<DefaultArgs>' is not assignable to type 'CustomerRevisionDefaultArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                          The types of 'select.project' are incompatible between these types.
                                            Type 'boolean | CustomerRevision$projectArgs<DefaultArgs>' is not assignable to type 'boolean | CustomerRevision$projectArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.
                                              Type 'CustomerRevision$projectArgs<DefaultArgs>' is not assignable to type 'boolean | CustomerRevision$projectArgs<InternalArgs & { result: { user: { fullName: () => { needs: { firstName: true; lastName: true; }; compute(user: { firstName: string; lastName: string; }): string; }; }; customerRevision: { ...; }; supplier: { ...; }; }; model: {}; query: {}; client: {}; }>'.

96         const workOrderItem = this.WorkOrderItem.delete({
                                                           ~
97             ...opt,
   ~~~~~~~~~~~~~~~~~~~
98             where: { id },
   ~~~~~~~~~~~~~~~~~~~~~~~~~~
99         });
   ~~~~~~~~~