Closed
Description
TypeScript Version: 2.1.4
Allowing indexing of indexable interfaces act similar to ES6 Map.get seems like it would help the type safety of the language.
Example:
interface Foo {
[name: string]: number
}
let foo: Foo = {};
let baz = foo["bar"];
// baz is of type number and compiles fine, even though is actually undefined
// possibly make baz of type (number | undefined) instead
Expected Behavior:
baz is of type (number | undefined)
Actual Behavior:
baz is of type number, despite actually being type undefined