Created
April 20, 2020 15:18
-
-
Save Pogix3m/1d9b1e32f428e8017ad2e6380e3a8241 to your computer and use it in GitHub Desktop.
Serialize BigInt in TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* tslint:disable: interface-name */ | |
export {}; | |
declare global { | |
interface BigInt { | |
toJSON(): string; | |
} | |
} | |
BigInt.prototype.toJSON = function(): string { | |
return `${this.toString()}n`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment