Skip to content

Instantly share code, notes, and snippets.

@miyaokamarina
Created October 1, 2018 15:23
Show Gist options
  • Save miyaokamarina/9c8ae3aff2d847675ce9df0d302d27ea to your computer and use it in GitHub Desktop.
Save miyaokamarina/9c8ae3aff2d847675ce9df0d302d27ea to your computer and use it in GitHub Desktop.
Safe JSON type in TypeScript
interface JsonArray extends Array<JsonValue> {}
interface JsonObject {
[key: string]: JsonValue;
}
export type JsonValue = null | boolean | number | string | JsonArray | JsonObject;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment