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

204
Visualizações
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 à 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