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

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