Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

get type of element of array typescript

const animals = ['cat', 'dog', 'mouse'] as const
type Animal = typeof animals[number]

// type Animal = 'cat' | 'dog' | 'mouse'
Source by steveholgado.com #
 
PREVIOUS NEXT
Tagged: #type #element #array #typescript
ADD COMMENT
Topic
Name
5+8 =