Skip to content

Instantly share code, notes, and snippets.

@urain39
Created January 27, 2021 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urain39/5588e35fdb87f159331f5576698516a1 to your computer and use it in GitHub Desktop.
Save urain39/5588e35fdb87f159331f5576698516a1 to your computer and use it in GitHub Desktop.
JSON Type annotation for TypeScript.
interface IMap<V> {
[key: string]: V | V[];
[index: number]: V | V[];
}
type JSONPrimitiveType = number | string | boolean | null;
interface JSONObjectType extends IMap<JSONPrimitiveType | JSONObjectType> {};
interface JSONArrayType extends Array<JSONPrimitiveType | JSONObjectType | JSONArrayType> {};
export type JSONType = JSONPrimitiveType | JSONObjectType | JSONArrayType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment