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

175
Views
Typescript extend prototype of external library

Given a library l that exports a class C in the namespace N like this:

export namespace N {
   export class C {
      public function f1(){return true}
   } 
}

and can be used with

import {N} from 'l'

console.log(new N().C.f1())

I can easily do

//@ts-ignore
N.C.prototype.f2 = ()=>return false

//@ts-ignore
console.log(new N().C.f2()

But how can I tell typescript that I extended the prototype and get rid of the //@ts-ignore

All solutions I found described how to extend objects in the global namespace like Array or String

Additional Info

The actual library I want to extend is @js-temporal/polyfill because the Duration.compare() method which returns 1, 0 or -1 is fairly unreadable and I want to add a Duration.greaterThan() method

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