Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!