bcherny/json-schema-to-typescript

Maximum call stack size exceeded

Open

#614 opened on Aug 7, 2024

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

Repository metrics

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

Description

a.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "oneOf": [
    { "$ref": "b.json" }
  ]
}

b.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "oneOf": [
    { "type": "string" },
    {
      "type": "array",
      "items": { "$ref": "#" }
    }
  ]
}

Then

json2ts a.json

results in

[
  RangeError: Maximum call stack size exceeded
      at memoized (/opt/homebrew/lib/node_modules/json-schema-to-typescript/node_modules/lodash/lodash.js:10612:30)
      at /opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:247:66
      at Array.map (<anonymous>)
      at generateSetOperation (/opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:247:32)
      at generateRawType (/opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:236:20)
      at generateTypeUnmemoized (/opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:128:18)
      at memoized (/opt/homebrew/lib/node_modules/json-schema-to-typescript/node_modules/lodash/lodash.js:10620:27)
      at /opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:145:55
      at generateRawType (/opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:147:15)
      at generateTypeUnmemoized (/opt/homebrew/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:128:18)
]

Contributor guide