Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
How to handle input value in typescript?

I want to add Typescript to an existing project.
The problem is that the type to be used as an input value is ambiguous.
Because in an existing project, I only used a string value as an input value.
For example, when I enter an price, I used to initialize it with an empty string value("") to see the placeholder at first.
Only numeric string can be entered via validation function and added comma to value when blur event is fired.

However, when I send it to the backend, I changed it to a number so all the data I get from the backend is a numeric type.
I'm trying to define data and types on the redux, but is it right to just declare it as a union type?
Or is there a better way?

This is the item type that I defined.
I want to use quantity and price as input value, but it's type is number so, I got a type error.

export interface Item {
    id: number
    category: string
    quantity: number
    price: number;
}

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda