Closed
Description
TypeScript Version: nightly (2.0.0-dev.201xxxxx)
Relevant StackOverflow discussion
Kudos to @nitzantomer for looking into this
Code
// This is defined in a d.ts file.
class Test {
someObj: {
someString: 'this'|'that'|'the other'
};
}
// This is me actually using the class.
class Test2 implements Test {
someObj = {
someString: 'this'
}
}
Expected behavior:
No error thrown. Using literal 'this'
as the value for someObj.someString
correctly implements class.
Actual behavior:
Error thrown.
Class 'Test2' incorrectly implements interface 'Test'.
Types of property 'someObj' are incompatible.
Type '{ someString: string; }' is not assignable to type '{ someString: "this" | "that" | "the other"; }'.
Types of property 'someString' are incompatible.
Type 'string' is not assignable to type '"this" | "that" | "the other"'.
Type 'string' is not assignable to type '"the other"'.