Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda