Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

use array element as types

const arrayWithAllFruitsAsvalues = ['apple', 'peach'] as const;

type Fruit = typeof arrayWithAllFruitsAsvalues[number];  // "apple" | "peach"

const objectWithAllFruitsAsKeys: {
  [ key in Fruit ]: any
} = { apple: '', peach: '' }
Comment

PREVIOUS NEXT
Code Example
Typescript :: Unhandled promise rejection: TypeError: ImagePicker.requestMediaLibraryPermissionsAsync is not a function. 
Typescript :: Count pets the types of pets in a columns 
Typescript :: typescript annotation 
Typescript :: code converter from javascript to typescript 
Typescript :: typescript dictionary usestate 
Typescript :: add and edit in ionic page 
Typescript :: nunjucks if logical or 
Typescript :: routerextensions nativescript 7 import 
Typescript :: how many type of mosfet are there 
Typescript :: AFTER RESETTING ANGULAR FORM I AM GETTING RED INVALID FORM 
Typescript :: generic function typescript 
Typescript :: react update state array of objects hooks 
Typescript :: angular conditional directives 
Typescript :: how to add type using map in typescript 
Typescript :: Git command to check for any conflicts between new and old versions on your repository 
Typescript :: inline scripts encapsulated in <script tags 
Cpp :: how to disable buttons in unity 
Cpp :: c++ vector decimal to binary 
Cpp :: c++ message box error 
Cpp :: how to iterate through a map in c++ 
Cpp :: c++ chrono get milliseconds 
Cpp :: c++ vector pop first element 
Cpp :: sony pictures animation films produced 
Cpp :: find all occurrences of a substring in a string c++ 
Cpp :: ue4 get socket location c++ 
Cpp :: c++ save typeid 
Cpp :: certificate exe application 
Cpp :: differency between c++ std and stl 
Cpp :: c++ remove whitespace from string and keep the same size 
Cpp :: print vector 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =