Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!