You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{EventEmitter}from'events';interfaceTest<T>{on(event: 'error',listener: (error: any)=>any): this;on(event: `__${string}`,listener: (data: string,isError: true)=>any|((data: T,isError: false)=>any)): this;once(event: 'error',listener: (error: any)=>any): this;once(event: `__${string}`,listener: (data: string,isError: true)=>any|((data: T,isError: false)=>any)): this;emit(event: 'error',error: any): boolean;emit(event: `__${string}`,data: string,isError: true): boolean;emit(event: `__${string}`,data: T,isError: false): boolean;}classTest<T>extendsEventEmitter{publictest(){// In my case - I was using a package that could provide null, or any type of data, so they used `any` - but I was expecting a string.constdata: any='test';constkey=`__${dataasstring}`asconst;// In my case, I had 2 values that were nullable - the error, or the data. One of them is guranteed to be present, so "(a ?? b)!" is the way to go.constnullableProp1: T|null='test'asany;constnullableProp2: string|null='test'asany;// If you start writing out this line, it will compile with regular type errors until the 2nd parameter, at which point everything breaks.if(key)this.emit(key,(nullableProp1??nullableProp2)!,trueasboolean);}}
🙁 Actual behavior
The Typescript compiler fails to pick an overload, and seems to recurse down past the maximum stack call size. This is reflected in the browser console when on the playground, and of course, locally
🙂 Expected behavior
The Typescript compiler successfully picks an overload and continues on.
The text was updated successfully, but these errors were encountered:
didinele
changed the title
Maximum call stack exceeded.
Maximum call stack size exceeded
Feb 6, 2021
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The Typescript compiler fails to pick an overload, and seems to recurse down past the maximum stack call size. This is reflected in the browser console when on the playground, and of course, locally
🙂 Expected behavior
The Typescript compiler successfully picks an overload and continues on.
The text was updated successfully, but these errors were encountered: