typescript string literal method-overloading for events
<p>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: </p>

<pre><code>on(event: string, listener: Function): this;
on(event: 'endTag', listener: (name: string, location?: LocationInfo) =&gt; void): this;
</code></pre>

<p>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.  </p>

<p>Unfortunately in normal TypeScript you are not allowed to use string literals like above. You can define a string as a type... </p>

<pre><code>export type Open = "open";
export type Close = "close";
export type Error = "error";
</code></pre>

<p>...but you cannot declare method overloads that only differ by these string types. i.e. you are <strong>not</strong> allowed to do this at present: </p>

<pre><code>on(event:Open, cb:()=&gt;void){}
on(event:Close, cb:()=&gt;void){}
on(event:Error, cb:(e:string)=&gt;void){}
</code></pre>

<p>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? </p>