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

191
Vistas
Typescript Add types to libraries method arguments

I am using an external library pg-mem which exposes LibAdapters and it has a method createTypeormConnection which accepts few arguments but of type any.

export interface LibAdapters {
  createTypeormConnection(typeOrmConnection: any, queryLatency?: number): any;
}

I want to specify the exact type of these arguments as I am getting a lot of lint errors:

Unsafe return of an `any` typed value.eslint@typescript-eslint/no-unsafe-return

How can I specify the types of the arguments & return type of the method?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can extend exisiting types by using declaration merging:

declare module "pg-mem" {
    interface LibAdapters {
        createTypeormConnection(typeOrmConnection: SomeType, queryLatency?: number): SomeOtherType
    }
}

Note, that this will add overload of createTypeormConnection instead of overriding it, so if you call createTypeormConnection with value of type other than SomeType, you will still get any.

about 4 years ago · Juan Pablo Isaza Denunciar
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