Skip to content

Instantly share code, notes, and snippets.

@Pogix3m
Created April 20, 2020 15:18
Show Gist options
  • Save Pogix3m/1d9b1e32f428e8017ad2e6380e3a8241 to your computer and use it in GitHub Desktop.
Save Pogix3m/1d9b1e32f428e8017ad2e6380e3a8241 to your computer and use it in GitHub Desktop.
Serialize BigInt in TypeScript
/* 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