Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript recursive types

type NestedNumbers = number | NestedNumbers[]
const val: NestedNumbers = [3, 4, [5, 6, [7], 59], 221]
//another example
type RecursiveObject = {
  name: string;
  children?: RecursiveObject[];
};
const recursiveData = [
  {
    name: 'First',
    children: [
      {
        name: 'Second',
        children: [
          {
            name: 'Third',
            children: [
              {
                name: 'Fourth',
                children: [
                  {
                    name: 'Fifth',
                    children: [
                      // On and on...
                    ],
                  },
                ],
              },
            ],
          },
        ],
      },
    ],
  },
];
//Another example to implement type for json
type JSONPrimitive = string | number | boolean | null
type JSONValue = JSONArray | JSONObject | JSONPrimitive
type JSONObject = { [k: string]: JSONValue }
type JSONArray = JSONValue[]
Comment

PREVIOUS NEXT
Code Example
Typescript :: ganache 
Typescript :: remove all comments function in c 
Typescript :: tailwind base components utilities 
Typescript :: NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct the issues below and execute "vagrant reload": 
Typescript :: what is the use of potential difference 
Typescript :: from date and to date validation in angular 9 
Typescript :: typescript how to create an array instance 
Typescript :: path expo 
Typescript :: array of objects value repeat check 
Typescript :: loop through imports python 
Typescript :: object add property typescript 
Typescript :: search an array of objects with specific object property value 
Typescript :: simulate click typescript 
Typescript :: import xml elements in kotlin 
Typescript :: html table to csv 
Typescript :: pagination in typescript 
Typescript :: serenity.is hide form field 
Typescript :: react-native use typescript 
Typescript :: ignore hosts option in network proxy in ubuntu 16.04 
Typescript :: View and navigate your assignments (teacher) code for asp.net 
Typescript :: pandas get count of pair of elements in two columns 
Typescript :: fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break Identify output ? 
Typescript :: useCallback hook to fix useEffect re-render warning on function dependency 
Typescript :: typescript get type from promise 
Typescript :: get enum value dynamically typescript 
Typescript :: arrays in typescript 
Typescript :: makestyles material ui typescript 
Typescript :: empty form elements except jquery 
Typescript :: aws s3 list objects by size 
Typescript :: Where are WordPress Posts Stored 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =