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

321
Visualizações
How to create instance of callable interface in TypeScript?

I have an interface below with call signature inside it

type MyTest = {
  description: string;
  (x: number): number;
};

But I don't know how to create instance of this interface in TypeScript. I have tested 3 solution below and nothing worked

const test1: MyTest = {
  description: 'My Name' // error: Type '{ description: string; }' provides no match for the signature '(x: number): number'.
} 
const test2: MyTest = (myNumberInput: number) => myNumberInput.toString(); // error: Property 'description' is missing in type '(myNumberInput: number) => string' but required in type 'MyTest'.
const test3: MyTest = {
  description: 'My Name', // error: Type '{ description: string; }' has no call signatures.
  (myNumberInput: number) => myNumberInput.toString() // error: Cannot find name 'myNumberInput'. + 'number' only refers to a type, but is being used as a value here.
}

Please give me an instruction for this problem. Thank a lot and have nice day!

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