bcherny/json-schema-to-typescript

error for empty enums

Open

#463 aberto em 25 de jun. de 2022

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)TypeScript (449 forks)github user discovery
buggood first issuehelp wanted

Métricas do repositório

Stars
 (3.302 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Empty enums such as this

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "QueryMsg",
  "type": "string",
  "enum": []
}

produces

export type QueryMsg = ()

which fails as the syntax is not correct

 FAIL  __tests__/index.test.js
  ✕ compiles (186 ms)

  ● compiles

    SyntaxError: '=>' expected. (9:1)
      7 |
      8 | export type QueryMsg = ()
    > 9 |

I've pushed an example that reproduces the exact error https://github.com/pyramation/json-schema-to-typescript-sandbox/blob/main/__tests__/index.test.js#L4-L10

Guia do colaborador