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

class generate with "Declarations with initializers cannot also have definite assignment assertions." error #56

Open
x-etienne opened this issue Dec 19, 2023 · 1 comment · May be fixed by #68

Comments

@x-etienne
Copy link

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
@woodenfish
Copy link

Same issue

@ABHwan ABHwan linked a pull request Jul 2, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants