diff --git a/packages/fast-stable-stringify/src/__tests__/index-test.ts b/packages/fast-stable-stringify/src/__tests__/index-test.ts index 4014d247f174..0759913ed408 100644 --- a/packages/fast-stable-stringify/src/__tests__/index-test.ts +++ b/packages/fast-stable-stringify/src/__tests__/index-test.ts @@ -196,11 +196,9 @@ describe('fastStableStringify', function () { expect(stringify(value)).toBe(jsonStableStringify(value)); }); it('hashes bigints', function () { - expect(stringify(200n)).toMatch('"200"n'); - expect(stringify({ foo: 100n })).toMatch('{"foo":"100"n}'); - expect(stringify({ age: BigInt(100n), name: 'Hrushi' })).toMatch('{"age":"100"n,"name":"Hrushi"}'); - expect(stringify({ age: [BigInt(100n), BigInt(200n), BigInt(300n)] })).toMatch( - '{"age":["100"n,"200"n,"300"n]}', - ); + expect(stringify(200n)).toMatch('200n'); + expect(stringify({ foo: 100n, goo: '100n' })).toMatch('{"foo":100n,"goo":"100n"}'); + expect(stringify({ age: BigInt(100n), name: 'Hrushi' })).toMatch('{"age":100n,"name":"Hrushi"}'); + expect(stringify({ age: [BigInt(100n), BigInt(200n), BigInt(300n)] })).toMatch('{"age":[100n,200n,300n]}'); }); }); diff --git a/packages/fast-stable-stringify/src/index.ts b/packages/fast-stable-stringify/src/index.ts index fcccf1a884dd..ea3a4c3cd9ff 100644 --- a/packages/fast-stable-stringify/src/index.ts +++ b/packages/fast-stable-stringify/src/index.ts @@ -61,7 +61,7 @@ function stringify(val: unknown, isArrayProp: boolean) { case 'undefined': return isArrayProp ? null : undefined; case 'bigint': - return JSON.stringify(val.toString()) + 'n'; + return `${val.toString()}n`; case 'string': return JSON.stringify(val); default: