[Typescript] Recursive types (JSONValue)

V3:

type JSONValue = 
    | string
    | number
    | boolean
    | null
    | JSONArray
    | JSONObject;
type JSONArray = JSONValue[];
type JSONObect = {
  [k: string]: JSONValue
}

 

v4: you can use `JSONValue` for self reference

type JSONValue = 
    | string
    | number
    | boolean
    | null
    | JSONValue[]
    | {
      [k: string]: JSONValue
    }

 

posted @ 2022-08-22 15:55  Zhentiw  阅读(20)  评论(0编辑  收藏  举报