Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda