bcherny/json-schema-to-typescript

Add support for `unevaluatedProperties` keyword

Open

#442 opened on Feb 28, 2022

View on GitHub
 (3 comments) (19 reactions) (0 assignees)TypeScript (449 forks)github user discovery
enhancementgood first issuehelp wanted

Repository metrics

Stars
 (3,302 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Draft 2019-09 introduces the new keyword unevaluatedProperties, which seems not supported in this project yet.

A schema with "unevaluatedProperties": false will lead to the generated type definition containing an extra [k: string]: unknown; field, which is expected not to be seen.

Reproduction

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "title": "Foo",
  "properties": {
    "bar": {
      "type": "string"
    }
  },
  "unevaluatedProperties": false
}

yields

export interface Foo {
  bar?: string;
  [k: string]: unknown;
}

which is expected to be

export interface Foo {
  bar?: string;
}

instead.

Contributor guide