Promise Inheritance Surprise

Here's a little JavaScript/TypeScript pop quiz: how can signal in the following code be undefined , leading to a failure when you try to add the event listener? class CancelablePromise<T> extends Promise<T> { constructor( callback: (resolve, reject) => void, signal: AbortSignal ) { super((resolve, reject) => { function cancelHandler(_ev: Event) { reject(new Error("Canceled via signal.", { cause:…