glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
11.77k stars 1.04k forks source link

Add readonly option for TypeScript Language #2534

Closed inferrinizzard closed 3 months ago

inferrinizzard commented 3 months ago

Description

Adds a 'prefer-readonly' option to TypeScript output.

Related Issue

2280

Previous Behaviour / Output

export interface TopLevel {
    age:     number;
    country: Country;
    females: number;
    males:   number;
    total:   number;
    year:    number;
}

New Behaviour / Output

export interface TopLevel {
    readonly age:     number;
    readonly country: Country;
    readonly females: number;
    readonly males:   number;
    readonly total:   number;
    readonly year:    number;
}

How Has This Been Tested?

Added to test suite under quickTestRendererOptions

Screenshots (if appropriate):

N/a

dvdsgl commented 3 months ago

Why prefer-readonly and not readonly? All of the settings are preferences, no?