type Baa = { a: number, b: number };
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
function foo<P extends Baa>() {
const foo: { foo: string } & Omit<P, 'b'> = null as any;
const props: Baa = foo;
}
No error.
test.ts:6:11 - error TS2322: Type '{ foo: string; } & Pick<P, Exclude<keyof P, "b">>' is not assignable to type 'Baa'.
Property 'a' is missing in type '{ foo: string; } & Pick<P, Exclude<keyof P, "b">>'.
6 const props: Baa = foo;
~~~~~
TypeScript Version:
typescript@3.2.0-dev.20181011
typescript@3.1.3
typescript@3.0.3
Search Terms:
Code
Expected behavior:
No error.
Actual behavior:
Removing the
{ foo: string } &works.Removing the
Omitworks.Removing the
Pand usingBaadirectly works.Playground Link:
https://agentcooper.github.io/typescript-play/?ts=2.9.1#code/C4TwDgpgBAQghnKBeKBvKcBcUB2BXAWwCMIAnAGiiIH5t9iyoBfAbgChRIoB5AgS2AAeACqUA0gD5kUAAp8AxgGsRlAKIAPeQBs8AEwiDFEEAHsAZlFFRJE9mzN4c84HxM4oZkycEyoEdcAQOLoAzrAIEgAUAJRobFAJUPJuIcAeXtjonibYqaR8OADmzFAAZDz8QjKUAORENVIo+FpaGGFwOCDsiUkpaWCkJmAh2PCIKNnsTGxAA
Related Issues: