I have the following types in my project:
export interface BaseTravelpayoutsPricesV3Options {
currency?: string;
departure_at?: string;
return_at?: string;
direct?: boolean;
limit?: number;
page?: number;
sorting?: 'price' | 'route';
unique?: boolean;
one_way?: boolean;
}
export interface TravelpayoutsPricesV3OptionsWithOrigin {
origin: string;
}
export interface TravelpayoutsPricesV3OptionsWithDestination {
destination: string;
}
export interface TravelpayoutsPricesV3OptionsWithOriginAndDestination {
origin: string;
destination: string;
}
export type TravelpayoutsPricesV3Options = BaseTravelpayoutsPricesV3Options & (TravelpayoutsPricesV3OptionsWithOrigin | TravelpayoutsPricesV3OptionsWithDestination | TravelpayoutsPricesV3OptionsWithOriginAndDestination);
Now when I’m trying to omit some property from that type for function argument, tha call says I’m specifiyng unknown property even though it’s not the one I omitted.
function test(options: Omit<TravelpayoutsPricesV3Options, 'limit'>) {
return 'foo';
}
test({
origin: 'test', // Object literal may only specify known properties, and 'origin' does not exist in type 'Omit<TravelpayoutsPricesV3Options, "limit">'
})
Why does that happen?