-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
// A *self-contained* demonstration of the problem follows...
function f<T, K extends keyof T>(obj: T, k: K, value:T[K]) {
for (let key in obj) {
value = obj[key];
break;
}
return value;
}
f({ x: 1, y: "" }, 'y', "1").charAt(0); //runtime error
Expected behavior:
Compiler error
Actual behavior:
Runtime error
jcalz
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue