Skip to content

Add support for [TsRequired] attribute to generate required TypeScript fields (fieldName!: type) #218

Description

@philac105

Currently, TypeGen does not provide a TypeAnnotations attribute to mark a property or field as required in the generated TypeScript code. This is needed to generate fields with the non-null assertion operator (!), which indicates that the field is required but not initialized in the constructor.

Expected behavior:
Introduce a [TsRequired] attribute.
When applied, the generated TypeScript property should use the ! operator.
This should work for both properties and fields.
Use case:
This is useful for strict TypeScript projects where required fields must be explicitly marked, improving type safety and compatibility with TypeScript's strict property initialization checks.

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