json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

Add optional support for TypeScript's bigint

Open KtorZ opened this issue 4 years ago • 0 comments

  • 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.

KtorZ avatar Aug 04 '21 21:08 KtorZ