I'm currently utilizing graphql-codegen which generates types in the following structure:
type Price = {
onetime: number;
monthtly: number;
};
type CarModel = {
price: Price;
name: string;
};
type Car = {
model: CarModel;
someOtherAttribute: string;
};
type MyCarQuery = Pick<Car, "someOtherAttribute"> & {
model: Pick<CarModel, "name"> & {
price: Pick<Price, "onetime">;
};
};
I am interested in isolating the type of
MyCarQuery -> model -> price
and using it independently. Essentially, I want to create a type definition for Pick<Price, "onetime">
without redundant definitions.
Is there a method to achieve this without duplicating the types?