Closed
Description
openedon Mar 20, 2017
TypeScript Version: 2.2.1
Code
function myValueArg(arg: "value") { }
function myStringArg(arg: string) { }
namespace ns { // Not needed, but shows it's not scope related
let str = "value";
if (str === "value") {
myValueArg(str);
[].forEach(() => {
myValueArg(str); // Argument of type 'string' is not assignable to parameter of type '"value"'.
});
} else {
myStringArg(str);
[].forEach(() => {
myStringArg(str);
});
}
}
Expected behavior:
No warnings: the value (and type) of str
has not changed.
Actual behavior:
Warning Argument of type 'string' is not assignable to parameter of type '"value"'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment