You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type { type: 'foo' | 'bar', bar: 'eggs' } shouldn't be assignable to type Field.
Type { type: 'foo' | 'bar' } should be assignable to type Field.
Type { type: 'bar', bar: 'eggs' } should be assignable to type Field.
Type { type: 'foo', bar: 'eggs' } shouldn't be assignable to type Field.
Actual behavior:
Both of types { type: 'foo' | 'bar', bar: 'eggs' } and { type: 'foo' | 'bar' } aren't assignable to type Field.
Both of types { type: 'bar', bar: 'eggs' } and { type: 'foo', bar: 'eggs' } are assignable to type Field.
First case compiles with an error:
test3.ts(21,5): error TS2322: Type '{ type: "foo"|"bar";}' is not assignable to type 'FooField|BarField'.Type'{ type: "foo" | "bar"; }'isnotassignabletotype'BarField'.Typesofproperty'type'areincompatible.Type'"foo" | "bar"'isnotassignabletotype'"bar"'.Type'"foo"'isnotassignabletotype'"bar"'.
Second case compiles without an error.
The text was updated successfully, but these errors were encountered:
Type { type: 'foo' | 'bar', bar: 'eggs' } shouldn't be assignable to type Field.
and it is.
Type { type: 'foo' | 'bar' } should be assignable to type Field.
Not relay. type { type: 'foo' | 'bar' } is not assignable to neither FooField nor BarField. it is easy to see why both are the same if you have more than one property. e.g: {a : string | number, b: string | number } is not assignable to {a: string, b: string} | {a: number, b: number}. you can see more discussion about this in #7274
Type { type: 'bar', bar: 'eggs' } should be assignable to type Field.
and it is.
Type { type: 'foo', bar: 'eggs' } shouldn't be assignable to type Field.
It is not assignable to BarField, since type is not "bar", but it is assignable to FooField, nothing in FooField says that bar can not be there. The excess property checking is done over names, and not types, so it is not triggered here.
TypeScript Version:
1.8.9
Code
Starting point:
First case:
Second case:
Expected behavior:
Type { type: 'foo' | 'bar', bar: 'eggs' } shouldn't be assignable to type Field.
Type { type: 'foo' | 'bar' } should be assignable to type Field.
Type { type: 'bar', bar: 'eggs' } should be assignable to type Field.
Type { type: 'foo', bar: 'eggs' } shouldn't be assignable to type Field.
Actual behavior:
Both of types { type: 'foo' | 'bar', bar: 'eggs' } and { type: 'foo' | 'bar' } aren't assignable to type Field.
Both of types { type: 'bar', bar: 'eggs' } and { type: 'foo', bar: 'eggs' } are assignable to type Field.
First case compiles with an error:
Second case compiles without an error.
The text was updated successfully, but these errors were encountered: