When using a Pick method on a type that contains optional parameters the resulting type will contain all of those optional parameters regardless of what the path argument is.
interface Test {
foo: string;
bar?: string;
}
type pickedTest = O.P.Pick<Test, ['foo']>;
pickedTest contains foo and optional bar property.
Type pickedTest contains only foo property.
I want to use it to type GraphQL queries and excluding certain properties is critical for building the returned object type correctly.
Thanks for reporting this. I will start fixing this tomorrow.
Fixed. Let me know if it's all good.
I added tests to make sure there's no regression. And added docs for Object.P.
Happy coding!
Thanks for quick response and a fix! Seems to be working correctly.
Although, I've got a new question about how to pick two different paths of an object that have different subobject names and if that is even possible. I'll file a new ticket for that.
Most helpful comment
Thanks for reporting this. I will start fixing this tomorrow.