1 | declare const assignmentCompatibilityHack: unique symbol;
|
2 | export declare type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
|
3 | export declare type VoidKeys<Record> = MatchingKeys<Record, void>;
|
4 | export interface TypeRecord<T, U, V> {
|
5 | ' _emitterType'?: T;
|
6 | ' _eventsType'?: U;
|
7 | ' _emitType'?: V;
|
8 | }
|
9 | export declare type ReturnTypeOfMethod<T> = T extends (...args: any[]) => any ? ReturnType<T> : void;
|
10 | export declare type ReturnTypeOfMethodIfExists<T, S extends string> = S extends keyof T ? ReturnTypeOfMethod<T[S]> : void;
|
11 | export declare type InnerEEMethodReturnType<T, TValue, FValue> = T extends (...args: any[]) => any ? ReturnType<T> extends void | undefined ? FValue : TValue : FValue;
|
12 | export declare type EEMethodReturnType<T, S extends string, TValue, FValue = void> = S extends keyof T ? InnerEEMethodReturnType<T[S], TValue, FValue> : FValue;
|
13 | declare type ListenerType<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
|
14 | export declare type OverriddenMethods<TEmitter, TEventRecord, TEmitRecord = TEventRecord> = {
|
15 | on<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: ListenerType<TEventRecord[P]>) => void): EEMethodReturnType<TEmitter, 'on', T>;
|
16 | on(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
17 | addListener<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: ListenerType<TEventRecord[P]>) => void): EEMethodReturnType<TEmitter, 'addListener', T>;
|
18 | addListener(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
19 | addEventListener<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: ListenerType<TEventRecord[P]>) => void): EEMethodReturnType<TEmitter, 'addEventListener', T>;
|
20 | addEventListener(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
21 | removeListener<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: any[]) => any): EEMethodReturnType<TEmitter, 'removeListener', T>;
|
22 | removeListener(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
23 | removeEventListener<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: any[]) => any): EEMethodReturnType<TEmitter, 'removeEventListener', T>;
|
24 | removeEventListener(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
25 | once<P extends keyof TEventRecord, T>(this: T, event: P, listener: (...args: ListenerType<TEventRecord[P]>) => void): EEMethodReturnType<TEmitter, 'once', T>;
|
26 | once(event: typeof assignmentCompatibilityHack, listener: (...args: any[]) => any): void;
|
27 | emit<P extends keyof TEmitRecord, T>(this: T, event: P, ...args: ListenerType<TEmitRecord[P]>): EEMethodReturnType<TEmitter, 'emit', T>;
|
28 | emit(event: typeof assignmentCompatibilityHack, ...args: any[]): void;
|
29 | };
|
30 | export declare type OverriddenKeys = keyof OverriddenMethods<any, any, any>;
|
31 | export declare type StrictEventEmitter<TEmitterType, TEventRecord, TEmitRecord = TEventRecord, UnneededMethods extends Exclude<OverriddenKeys, keyof TEmitterType> = Exclude<OverriddenKeys, keyof TEmitterType>, NeededMethods extends Exclude<OverriddenKeys, UnneededMethods> = Exclude<OverriddenKeys, UnneededMethods>> = TypeRecord<TEmitterType, TEventRecord, TEmitRecord> & Pick<TEmitterType, Exclude<keyof TEmitterType, OverriddenKeys>> & Pick<OverriddenMethods<TEmitterType, TEventRecord, TEmitRecord>, NeededMethods>;
|
32 | export default StrictEventEmitter;
|
33 | export declare type NoUndefined<T> = T extends undefined ? never : T;
|
34 | export declare type StrictBroadcast<TEmitter extends TypeRecord<any, any, any>, TEmitRecord extends NoUndefined<TEmitter[' _emitType']> = NoUndefined<TEmitter[' _emitType']>, VK extends VoidKeys<TEmitRecord> = VoidKeys<TEmitRecord>, NVK extends Exclude<keyof TEmitRecord, VK> = Exclude<keyof TEmitRecord, VK>> = {
|
35 | <E extends NVK>(event: E, request: TEmitRecord[E]): any;
|
36 | <E extends VK>(event: E): any;
|
37 | };
|
38 | export declare type EventNames<TEmitter extends TypeRecord<any, any, any>, TEventRecord extends NoUndefined<TEmitter[' _eventsType']> = NoUndefined<TEmitter[' _eventsType']>, TEmitRecord extends NoUndefined<TEmitter[' _emitType']> = NoUndefined<TEmitter[' _emitType']>> = keyof TEmitRecord | keyof TEventRecord;
|
39 | export declare type OnEventNames<TEmitter extends TypeRecord<any, any, any>, TEventRecord extends NoUndefined<TEmitter[' _eventsType']> = NoUndefined<TEmitter[' _eventsType']>, TEmitRecord extends NoUndefined<TEmitter[' _emitType']> = NoUndefined<TEmitter[' _emitType']>> = keyof TEventRecord;
|
40 | export declare type EmitEventNames<TEmitter extends TypeRecord<any, any, any>, TEventRecord extends NoUndefined<TEmitter[' _eventsType']> = NoUndefined<TEmitter[' _eventsType']>, TEmitRecord extends NoUndefined<TEmitter[' _emitType']> = NoUndefined<TEmitter[' _emitType']>> = keyof TEmitRecord;
|
41 |
|
\ | No newline at end of file |