mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
@@ -0,0 +1,15 @@
|
||||
//// [eventEmitterPatternWithRecordOfFunction.ts]
|
||||
interface A {
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
type Args<F> = F extends (...args: infer A) => void ? A : never;
|
||||
|
||||
type EventMap = Record<string, Function>;
|
||||
|
||||
interface B<M extends EventMap> extends A {
|
||||
emit<Event extends keyof M>(event: Event, ...args: Args<M[Event]>): boolean;
|
||||
}
|
||||
|
||||
//// [eventEmitterPatternWithRecordOfFunction.js]
|
||||
"use strict";
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/eventEmitterPatternWithRecordOfFunction.ts ===
|
||||
interface A {
|
||||
>A : Symbol(A, Decl(eventEmitterPatternWithRecordOfFunction.ts, 0, 0))
|
||||
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
>emit : Symbol(A.emit, Decl(eventEmitterPatternWithRecordOfFunction.ts, 0, 13))
|
||||
>event : Symbol(event, Decl(eventEmitterPatternWithRecordOfFunction.ts, 1, 9))
|
||||
>args : Symbol(args, Decl(eventEmitterPatternWithRecordOfFunction.ts, 1, 23))
|
||||
}
|
||||
|
||||
type Args<F> = F extends (...args: infer A) => void ? A : never;
|
||||
>Args : Symbol(Args, Decl(eventEmitterPatternWithRecordOfFunction.ts, 2, 1))
|
||||
>F : Symbol(F, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 10))
|
||||
>F : Symbol(F, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 10))
|
||||
>args : Symbol(args, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 26))
|
||||
>A : Symbol(A, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 40))
|
||||
>A : Symbol(A, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 40))
|
||||
|
||||
type EventMap = Record<string, Function>;
|
||||
>EventMap : Symbol(EventMap, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 64))
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
interface B<M extends EventMap> extends A {
|
||||
>B : Symbol(B, Decl(eventEmitterPatternWithRecordOfFunction.ts, 6, 41))
|
||||
>M : Symbol(M, Decl(eventEmitterPatternWithRecordOfFunction.ts, 8, 12))
|
||||
>EventMap : Symbol(EventMap, Decl(eventEmitterPatternWithRecordOfFunction.ts, 4, 64))
|
||||
>A : Symbol(A, Decl(eventEmitterPatternWithRecordOfFunction.ts, 0, 0))
|
||||
|
||||
emit<Event extends keyof M>(event: Event, ...args: Args<M[Event]>): boolean;
|
||||
>emit : Symbol(B.emit, Decl(eventEmitterPatternWithRecordOfFunction.ts, 8, 43))
|
||||
>Event : Symbol(Event, Decl(eventEmitterPatternWithRecordOfFunction.ts, 9, 9))
|
||||
>M : Symbol(M, Decl(eventEmitterPatternWithRecordOfFunction.ts, 8, 12))
|
||||
>event : Symbol(event, Decl(eventEmitterPatternWithRecordOfFunction.ts, 9, 32))
|
||||
>Event : Symbol(Event, Decl(eventEmitterPatternWithRecordOfFunction.ts, 9, 9))
|
||||
>args : Symbol(args, Decl(eventEmitterPatternWithRecordOfFunction.ts, 9, 45))
|
||||
>Args : Symbol(Args, Decl(eventEmitterPatternWithRecordOfFunction.ts, 2, 1))
|
||||
>M : Symbol(M, Decl(eventEmitterPatternWithRecordOfFunction.ts, 8, 12))
|
||||
>Event : Symbol(Event, Decl(eventEmitterPatternWithRecordOfFunction.ts, 9, 9))
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/eventEmitterPatternWithRecordOfFunction.ts ===
|
||||
interface A {
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
>emit : (event: string, ...args: any[]) => boolean
|
||||
>event : string
|
||||
>args : any[]
|
||||
}
|
||||
|
||||
type Args<F> = F extends (...args: infer A) => void ? A : never;
|
||||
>Args : Args<F>
|
||||
>args : A
|
||||
|
||||
type EventMap = Record<string, Function>;
|
||||
>EventMap : Record<string, Function>
|
||||
|
||||
interface B<M extends EventMap> extends A {
|
||||
emit<Event extends keyof M>(event: Event, ...args: Args<M[Event]>): boolean;
|
||||
>emit : <Event extends keyof M>(event: Event, ...args: Args<M[Event]>) => boolean
|
||||
>event : Event
|
||||
>args : Args<M[Event]>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @strict: true
|
||||
interface A {
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
type Args<F> = F extends (...args: infer A) => void ? A : never;
|
||||
|
||||
type EventMap = Record<string, Function>;
|
||||
|
||||
interface B<M extends EventMap> extends A {
|
||||
emit<Event extends keyof M>(event: Event, ...args: Args<M[Event]>): boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user