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

317
Vistas
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 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