mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
refactor typescript wiring
This commit is contained in:
parent
cea9ae62d8
commit
c62c336a11
286 changed files with 2999 additions and 3053 deletions
19
webclient/src/polyfills.ts
Normal file
19
webclient/src/polyfills.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Runtime polyfills that must execute before any other application module.
|
||||
// Import this file first from `src/index.tsx`.
|
||||
|
||||
// ── BigInt.prototype.toJSON ───────────────────────────────────────────────────
|
||||
// Protobuf-ES maps proto `int64`/`uint64` fields to native `BigInt`. Those
|
||||
// land in Redux state (e.g. `ServerInfo_User.accountageSecs`,
|
||||
// `Response_Register.deniedEndTime`, the outbound `cmdId`), and any consumer
|
||||
// that JSON-stringifies state — notably the Redux DevTools browser
|
||||
// extension, but also logging and error-boundary dumps — throws with
|
||||
// "Do not know how to serialize a BigInt" because `BigInt.prototype` has no
|
||||
// `toJSON`. Installing one globally makes `JSON.stringify` coerce
|
||||
// `BigInt → string` instead of throwing. Coercion is lossy but only affects
|
||||
// serialized representations; the in-memory Redux state still holds real
|
||||
// `BigInt`s and every consumer reads them via the generated proto accessors.
|
||||
(BigInt.prototype as unknown as { toJSON: () => string }).toJSON = function bigIntToJSON() {
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
export {};
|
||||
Loading…
Add table
Add a link
Reference in a new issue