bcherny/json-schema-to-typescript

Empty objects produce broken schema (empty interface)

Open

#486 geöffnet am 18. Sept. 2022

Auf GitHub ansehen
 (3 Kommentare) (1 Reaktion) (0 zugewiesene Personen)TypeScript (449 Forks)github user discovery
buggood first issuehelp wanted

Repository-Metriken

Stars
 (3.302 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

I searched a bit but didn't find any issues/discussion that looked relevant, please forgive me if I missed something.

I'm dealing with an api that has "sometype": {} fields sometimes (that is, it requires an empty object) with a definition like

{
  "title": "Empty",
  "type": "object",
  "properties": {},
  "additionalProperties": false
}

This produces the invalid ts definition

export interface Empty {}

where I'd expect

export type Empty = Record<string, never>;

Obviously there won't be significant type safety (or unsafety) in these situations, but it will compile/check.

Contributor Guide