TypeScript Version: 2.1.1 / nightly (2.2.0-dev.20170228)
Went to StackOverflow with this first and the consensus there seems to be that this is a bug.
Here's my question again for convenience:
Consider a situation where an object can have exactly the FooBar or Baz interface listed below.
interfaceFooBar{foo: string;bar: string;}interfaceBaz{baz: string;}It's my understanding that this "one or the other" situation can be handled by creating a union between FooBar and Baz.
typeFooBarOrBaz=FooBar|Baz;
So far so good...
The issue I'm having is that the following object passes type checking:
constx: FooBarOrBaz={foo: 'foo',baz: 'foo',};Expected behavior:x should not pass type checking. It's neither FooBar nor Baz, but rather a combination between the two.
Actual behavior:x passes type checking.
Playground Example
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.20170228)
Went to StackOverflow with this first and the consensus there seems to be that this is a bug.
Here's my question again for convenience:
Consider a situation where an object can have exactly the
FooBarorBazinterface listed below.It's my understanding that this "one or the other" situation can be handled by creating a union between
FooBarandBaz.So far so good...
The issue I'm having is that the following object passes type checking:
Expected behavior:
xshould not pass type checking. It's neitherFooBarnorBaz, but rather a combination between the two.Actual behavior:
xpasses type checking.Playground Example