Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal types are generated as number #55

Open
joao-moonward opened this issue Dec 6, 2023 · 0 comments
Open

Decimal types are generated as number #55

joao-moonward opened this issue Dec 6, 2023 · 0 comments

Comments

@joao-moonward
Copy link
Contributor

joao-moonward commented Dec 6, 2023

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant