bcherny/json-schema-to-typescript

Empty objects produce broken schema (empty interface)

Open

#486 建立於 2022年9月18日

在 GitHub 查看
 (3 留言) (1 反應) (0 負責人)TypeScript (449 fork)github user discovery
buggood first issuehelp wanted

倉庫指標

Star
 (3,302 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.

貢獻者指南