Closed
Description
TypeScript Version: 2.1.4
Code
function mergeObject<T extends any>(dst: T, src: T): T
{
for (var x in src)
{
dst[x] = src[x];
}
return dst;
}
interface Hash<T> { [key: string]: T; }
type EventHandler = (s: BaseEventDealer) => void;
interface BaseEventDealer
{
GetEventHandler(event: string): EventHandler;
}
class C implements BaseEventDealer
{
GetEventHandler(event: string) { return C.h[event]; }
static h : Hash<EventHandler> = {
a:function(s){}
}
}
class D extends C
{
GetEventHandler(event: string) { return D.h[event]; }
static h = mergeObject<Hash<EventHandler>>(
{
b:function(s:D){}
},C.h);
}
Expected behavior:
type of D.h should be Hash<EventHandler>
type of return value of D.GetEventHandler should be EventHandler
Actual behavior:
type of D.h and return value of D.GetEventHandler both is ImplicitAny
but if you remove D.GetEventHandler or change its name, h will get right type
or you manually declare h:Hash<EventHandler> or GetEventHandler(event: string):EventHandler, they will both get right type