L
L
lexstile2020-12-03 19:43:04
typescript
lexstile, 2020-12-03 19:43:04

What is the correct type for an immutable list of values?

There is an Input component, it has an inputMode prop - it has a strict list of string values.
What is the correct way to write this type?

export interface InputProps {
  inputMode?: string; // стринг нужно заменить на "один из значений"
}

export const Input = (props: InputProps) => {}


Apart from this, is there any other way to do it?
export type HttpMethod = 'head' | 'get' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2020-12-03
@lexstile

have you heard about enum?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question