I've not managed to find a neat solution to this as yet and I feel there should be one but I don't quite have enough experience with Typescript to know it as yet. I hav an interface which defines some keys allowed in an object used for pagination
interface PaginationOptions {
page: number;
limit: number;
}
My input object is a HTTP query ?page=1&limit=3&name=Foo
which translates to
{
name: "Foo",
page: 1,
limit: 3,
}
What I want it to be able to make two objects from that, an object containing all the values of the keys defined in the interface and an object that has any other key. At the moment I am iterating through the incoming object and picking them apart manually but can't help but think there is a better way. Below is an example of the two objects I want to make from the above.
{
page: 1,
limit: 3
}
and
{
name: "Foo"
}