Skip to content

Instantly share code, notes, and snippets.

@Jxck
Created October 3, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jxck/010463ac9e326badda883a1f2571c795 to your computer and use it in GitHub Desktop.
Save Jxck/010463ac9e326badda883a1f2571c795 to your computer and use it in GitHub Desktop.
declare global {
// EventTarget に on を生やすと addEventListener を on と書ける
// e.g. ws.on('message', ()=>{})
interface EventTarget {
on: typeof EventTarget.prototype.addEventListener;
}
}
WebSocket.prototype.on = WebSocket.prototype.addEventListener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment