Closed
Description
Apologies if this has been covered before an/or is not a bug but I can't seem to find it in the issue list or any discussion of it online.
TypeScript Version: 2.0.3
Given this code:
let danny: { [name: string]: string; } = {};
let whatIsMyType = danny["test2"];
the type of whatIsMyType
is string
(I would expect string | undefined
). This means I can write a method that pulls from the map and claims to return a string
without any warning:
getPackagePath(name: string): string {
return this.map[name];
}
Shouldn't | undefined
be added implicitly to the type returned from a map like this?