2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/functionSubtypingOfVarArgs.ts ===
|
|
|
|
class EventBase {
|
|
|
|
>EventBase : EventBase
|
|
|
|
|
|
|
|
private _listeners = [];
|
|
|
|
>_listeners : any[]
|
|
|
|
>[] : undefined[]
|
|
|
|
|
|
|
|
add(listener: (...args: any[]) => void): void {
|
|
|
|
>add : (listener: (...args: any[]) => void) => void
|
|
|
|
>listener : (...args: any[]) => void
|
|
|
|
>args : any[]
|
|
|
|
|
|
|
|
this._listeners.push(listener);
|
|
|
|
>this._listeners.push(listener) : number
|
|
|
|
>this._listeners.push : (...items: any[]) => number
|
|
|
|
>this._listeners : any[]
|
|
|
|
>this : EventBase
|
|
|
|
>_listeners : any[]
|
|
|
|
>push : (...items: any[]) => number
|
|
|
|
>listener : (...args: any[]) => void
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class StringEvent extends EventBase { // should work
|
|
|
|
>StringEvent : StringEvent
|
|
|
|
>EventBase : EventBase
|
|
|
|
|
|
|
|
add(listener: (items: string) => void ) { // valid, items is subtype of args
|
|
|
|
>add : (listener: (items: string) => void) => void
|
|
|
|
>listener : (items: string) => void
|
|
|
|
>items : string
|
|
|
|
|
|
|
|
super.add(listener);
|
|
|
|
>super.add(listener) : void
|
|
|
|
>super.add : (listener: (...args: any[]) => void) => void
|
2014-08-28 21:31:37 +02:00
|
|
|
>super : EventBase
|
2014-08-15 23:33:16 +02:00
|
|
|
>add : (listener: (...args: any[]) => void) => void
|
|
|
|
>listener : (items: string) => void
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|