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