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

291
Vistas
Extending Promise results in constructor called twice, how come?
class MyPromise<T = void> extends Promise<T> {
  started = false
  resolve: (t: T) => void = () => {}
  reject: (e: any) => void = () => {}
  constructor() {
    console.log('constructor')
    let resolve: (t: T) => void = () => {}
    let reject: (e: any) => void = () => {}
    super((res, rej) => {
      resolve = res
      reject = rej
    })
    this.resolve = resolve
    this.reject = reject
  }
}

const thing = new MyPromise<string>()
thing.resolve('a')
thing.then(t => console.log('then', t))

Constructor is called twice and I get this error

constructor
constructor
[TestError] TypeError: Promise resolve or reject function is not callable

Running on node 14.17.1

about 4 years ago · Santiago Trujillo
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