Typescript 1.8 introduced the string literal type. However, when passing in an object as a parameter as in the following:
const test = {
a: "hi",
b: "hi",
c: "hi"
};
interface ITest {
a: "hi" | "bye"
}
function testFunc (t: ITest) {
}
testFunc(test);
It fails with:
Argument of type '{ a: string; b: string; c: string; }' is not assignable to parameter of type 'ITest'. Types of property 'a' are incompatible. Type 'string' is not assignable to type '"hi" | "bye"'. Type 'string' is not assignable to type '"bye"'.
I would expect this to work since it meets the requirements of the interface, but I might be overlooking something.