Closed
Description
TypeScript Version: 3.3.0-dev.20181201
Search Terms:
- generic
- pick
- exclude
- spread
Code
type TargetProps = {
foo: string,
bar: string
};
const modifier = <T extends TargetProps>(targetProps: T) => {
let {bar, ...rest} = targetProps;
let result: typeof rest & {bar: string}
// 'foo' doesn't exist
rest.foo;
// Type 'Pick<T, Exclude<keyof T, "bar">> & { bar: string; }' is not assignable to type 'T'.
let combined: T = result;
};
Expected behavior:
Rest properties of an object, which has a generic type, should be accessible after the spread operator was applied.
Actual behavior:
None of the properties described in the base TargetProps
type can be accessed.
Playground Link: link
Related Issues: