Some typing definitions I've been using have declared some method overloads with string literals. So in an ambient d.ts file, I've seen:
on(event: string, listener: Function): this;
on(event: 'endTag', listener: (name: string, location?: LocationInfo) => void): this;
and this results in nice intellisence in VSCode that will lists each event and the different function overrides you need to use for each of them.
Unfortunately in normal TypeScript you are not allowed to use string literals like above. You can define a string as a type...
export type Open = "open";
export type Close = "close";
export type Error = "error";
...but you cannot declare method overloads that only differ by these string types. i.e. you are not allowed to do this at present:
on(event:Open, cb:()=>void){}
on(event:Close, cb:()=>void){}
on(event:Error, cb:(e:string)=>void){}
Is there a way to define a method so that it brings up intellisense showing the different event names and the parameter overloads corresponding to those events?