Skip to content

Decimal types are generated as number #55

@ghost

Description

Expected Behavior

Perhaps we could add a new setting called 'preserveDecimal' to the library, which would allow users to choose how Decimal values are generated. By default, this setting would be set to false.

Example of output when it set to true:

@ApiProperty({ type: Number })
landSize: Prisma.Decimal;

I am proposing a solution to make all my DTO payloads type-safe by following Prisma includes. In the end it helps me to better document my APIs.

class UserDto extends IntersectionType(
    PrismaModel.User,
    PickType(PrismaModel.UserRelations, ['address','documents']),
  )
  implements
    Prisma.UserGetPayload<{
      include: typeof UserDto.include;
    }>{


 static get include() {
    return Prisma.validator<Prisma.UserInclude>()({
      address: true,
      documents: true,
    })
 }
}

The Decimal type is generating as a number, which causes type incompatibilities. The temporary solution I have found so far is to ignore it:

  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore: Unreachable code error

If I find the time, I can work on this and suggest a solution.

Actual Behavior

The output is in number type:

@ApiProperty({ type: Number })
landSize: number;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions