Closed
Description
TypeScript Version: 2.7.0-dev.201xxxxx
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
interface TypeA {
test: "test1" | "test2" | "test3"
}
function fn(param: TypeA) {
}
// Check pass
fn({
test: "test1"
});
// The same object, but passed by object reference
let obj = {
test: "test1"
};
/**
* Error:(26, 4) TS2345: Argument of type '{ test: string; }' is not assignable to parameter of type 'TypeA'.
* Types of property 'test' are incompatible.
* Type 'string' is not assignable to type '"test1" | "test2" | "test3"'.
*/
fn(obj);
Expected behavior:
Check pass
Actual behavior:
I get a TS2345