From what I understand, the as keyword allows you to omit properties... but it doesn't seem to work when union types are involved...
interface Foo {
foo: string;
bar: Bar;
baz: Baz;
union: Bar | Baz;
}
interface Bar {
bar: string;
}
interface Baz {
baz: string;
}
let this_works = {
foo: 'hello'
} as Foo;
let this_also_works1 = {
bar: { bar: 'hello' }
} as Foo;
let this_also_works2 = {
baz: { baz: 'hello' }
} as Foo;
let union_cant_be_assigned_unless_all_other_properties_assigned = {
union: { bar: 'hello' }
} as Foo;
I've tested on TypeScript 1.7.5 (current release) and typescript@next (Version 1.9.0-dev.20160205)