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

202
Views
How to have each element of an object keep its type without naming them implicitly in Typescript (typegoose,typegraphql)
export interface ObjectInterface{
  [key: string]: string | number | string[];
}

this is a interface I'm using, imported to the function(given below) from types.ts

the code below is for a function doing something

async createTaskService({
    A,
    B,
    C,
  }: ObjectInterface) {
      A = A as string
      B = B as string[]
      C = C as number
      //other stuff --unrelated
  }

Restrictions are that the keys of ObjectInterface cannot be "named" as in the keys must remain variable strings. What I want to know is if there's a better way to accept the parameters and set their types rather than doing X = X as string etc.

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!