Problem statement
I would like to start with an interface that has many overloaded call signatures, and replace one of them with a different signature. This means that I have to omit a particular signature from the base interface before adding its replacement.
Goal
Presume that I start with this interface:
interface Foo {
(options: {method: 'authorize', userId: number}): Promise<string>;
(options: {method: 'deauthorize', authToken: string}): Promise<boolean>;
}
And I want to end with this interface:
interface Bar {
(options: {method: 'authorize', userToken: string}): Promise<string>; // NEW
(options: {method: 'deauthorize', authToken: string}): Promise<boolean>; // UNALTERED
}
What I've tried
I tried to use the Exclude utility type to remove the unwanted signature.
type BaseInterface = Exclude<Foo, (options: {method: 'authorize', userId: number}) => Promise<string>>;
interface Bar extends BaseInterface {
(options: {method: 'authorize', userToken: string}): Promise<string>;
}
…but that just resulted in BaseInterface being of type never.