diff --git a/HISTORY.md b/HISTORY.md index ee37f99cc..a00e40ade 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,10 @@ # History +# unpublished changes since 13.0.2 + +- Fix: #3232 fix type definitions of function `format` to support notations + `hex`, `bin`, and `oct`. + # 2024-07-04, 13.0.2 - Fix an error in the type definitions of `quantileSeq` (#3223). diff --git a/test/typescript-tests/testTypes.ts b/test/typescript-tests/testTypes.ts index d3419a2c6..738963ae4 100644 --- a/test/typescript-tests/testTypes.ts +++ b/test/typescript-tests/testTypes.ts @@ -2168,6 +2168,9 @@ Factory Test const d = divide(a, b) assert.strictEqual(format(c), '16/21') assert.strictEqual(format(d), '7/9') + assert.strictEqual(format(255, { notation: 'bin' }), '0b11111111') + assert.strictEqual(format(255, { notation: 'hex' }), '0xff') + assert.strictEqual(format(255, { notation: 'oct' }), '0o377') } /** diff --git a/types/index.d.ts b/types/index.d.ts index 37603ac13..fd4e1f0c3 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -4352,7 +4352,14 @@ export interface FormatOptions { * elsewhere. Lower bound is included, upper bound is excluded. For * example '123.4' and '1.4e7'. */ - notation?: 'fixed' | 'exponential' | 'engineering' | 'auto' + notation?: + | 'fixed' + | 'exponential' + | 'engineering' + | 'auto' + | 'hex' + | 'bin' + | 'oct' /** * A number between 0 and 16 to round the digits of the number. In case