Created
July 28, 2020 16:37
-
-
Save hmmhmmhm/c7f59a64d7794631585ddb1d8a6379ef to your computer and use it in GitHub Desktop.
타입스크립트 이벤트 에미터 타입 힌트 방법 (Typescript EventEmitter Type Hint Solution)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { EventEmitter } from 'events' | |
| export interface IEventSet { | |
| on(event: 'changed', listener: (name: string) => void): this | |
| on(event: 'deleted', listener: (name: string) => void): this | |
| } | |
| const MyEvent: EventEmitter & IEventSet = new EventEmitter() | |
| const myEvent = new MyEvent() | |
| // myEvent.on("") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
간단하게 typescript 에서 이벤트 구성 시 자동 왼성으로 이벤트 명이 목록으로 추천될 수 있게 하는 방법 예시를 만들어 보았습니다.