json-schema-to-typescript
json-schema-to-typescript copied to clipboard
Add optional support for TypeScript's bigint
- This change isn't changing any of the existing behavior by default.
- When enabled however, it'll generate integers with no 'maximum' property as 'bigint'.
Why?
While JSON supports big integers in its specification, JavaScript does not by default. Thus, trying to deserialise a large integer into a JavaScript number is doomed to fail. Since relatively recently however, JavaScript (and therefore TypeScript), natively supports a 'bigint' type for numbers (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt), and there exists fixed parsers that can parse numbers into bigint directly.