prisma-class-generator
prisma-class-generator copied to clipboard
class generate with "Declarations with initializers cannot also have definite assignment assertions." error
Expected Behavior
Generate the class without annoying error "Declarations with initializers cannot also have definite assignment assertions." and for number type generate a default value as Date.
Actual Behavior
Actualy when I generate a class, when a property in the schema has a default value, the generator create a class with error
Steps to Reproduce the Problem
With this schema
generator client {
provider = "prisma-client-js"
output = env("PRISMA_CLIENT_PATH")
}
generator prismaClassGenerator {
provider = "prisma-class-generator"
dryRun = false
useSwagger = false
makeIndexFile = false
separateRelationFields = false
useNonNullableAssertions = true
output = "./models"
}
datasource db {
provider = "sqlite"
url = env("PRISMA_DATABASE_URL")
}
model test{
id String @id
description String?
value Int @default(1)
}
The generator create this class
export class item {
id!: string; // here for me is correct
description?: string;
value!: number = new Date('1');; // <- this is the problem, the ! and type of value (Date instead of number)
}
Specifications
- Version: 0.2.9
- Prisma Version: 5.3.0
- Platform: windows10
Same issue