Optionally add Definite Type Assertion
Closed this issue · 3 comments
Firstly, can I say kudos for taking this library forward and your enhancements - it's so great to be able to use Prisma as the single source of truth for the model, DTOs, validation and OpenAPI.
One suggestion: fields in DTO and entity classes could (optionally) be specified with the Definite Type Assertion !
prefix. This is so that we don't need to set "strictPropertyInitialization": false
in tsconfig.json
.
For example, the schema:
integerField: Int
stringField: String
... the generated fields are:
integerField: number;
stringField: string;
It would be great to be able instead to output
integerField!: number;
stringField!: string;
Definite Type Assertion was specifically added to Typescript to account for scenarios where fields are not necessarily initialised in a constructor but populated by an external library - exactly as with a DTO. Docs
Good point. Should be a rather easy enhancement. Maybe I'll be able to do it this week,
With the latest release, you can now set the flag definiteAssignmentAssertion = "true"
to add the definite assignment assertion operator !
to properties.
Brilliant, thanks!