Closed ilanashapiro closed 1 year ago
@rattrayalex @RobertCraigie
@daniel-white Hi! Could someone from your team please take a look at this PR? Thanks!
Heyo! I'll take a look at the PR soon
:tada: This PR is included in version 6.0.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Currently,
MAX_INT_64
is set to2 ** 63 - 1
, andMIN_INT_64
is set to0 - 2 ** 63
insrc/oas/transformers/schema/keywords/format.ts
. The TypeScript compiler evaluates these, respectively, to 9223372036854776000 and -9223372036854776000.Motivation and Context
These values are outside the range of int64 and result in bugs in clients such as Prism that use this library (e.g. https://github.com/stoplightio/prism/issues/1992).
The reasoning behind this erroneous calculation is explained here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER. Essentially, we are overflowing the capacity of JavaScript's Number type, and beyond Number.MAX_SAFE_INTEGER + 1 (9007199254740992), the IEEE-754 floating-point format can no longer represent every consecutive integer (see: https://stackoverflow.com/questions/1379934/large-numbers-erroneously-rounded-in-javascript).
Description
Thus, instead of setting
MAX_INT_64
to2 ** 63 - 1
, andMIN_INT_64
to0 - 2 ** 63
, we set them to TypeScript's built-in Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER instead.How Has This Been Tested?
Update local tests including screenshot tests.
Types of changes
Checklist