json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

`type: null` generated as "any object" record

Open fastcat opened this issue 4 months ago • 0 comments

Schema:

$schema: "https://json-schema.org/draft/2020-12/schema"
type: object
additionalProperties: false
required: [nullProp]
properties:
    nullProp:
        type: null

Generate with: npx --package=json-schema-to-typescript@^15 json2ts -i schema.yaml -o schema.ts Produces (minus headers):

export interface Schema {
  nullProp: {
    [k: string]: unknown;
  };
}

Expected:

export interface Schema {
  nullProp: null;
}

Workaround: use tsType

fastcat avatar Jul 31 '25 18:07 fastcat