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

171
Visualizações
pass value to generic to get type typescript

I have a function

function getExtendedObject<T extends object>( currentObject: T ) {
  return {
    ...currentObject,
    newProp: "value1",
    anotherProp: () => "something"
  }
}

i need to get the return type of this function for a specific input.

type example = ReturnType<typeof getExtendedObject>

the above will give me

type example = object & {
    newProp: string;
    anotherProp: number;
}

but instead of object, i want a specific value. something like,

type example = { name: "john", marks: 91 } & {
    newProp: string;
    anotherProp: number;
}

how can i achieve this

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