Is it possible to create a new function definition based on an existing one?
For example, I have a third-party library that has the following two functions:
declare function v1(s: string, t: string): string;
declare function v2(n: number): string;
I have a function that was written in JS but recently has been requested to add Typescript definitions. My function looks like the following:
function useId(version, ...args) {
return generators[version](...args);
}
What I would like to do is take the existing v1 and v2 declarations and use them in my own like so:
declare function useId(v: "v1", ...v1): string;
declare function useId(v: "v2", ...v2): string;
I have not been able to find any advanced typings that cover this specific need but wanted to check before taking a longer more verbose route to adding my function definitions (given they'll be duplicates with one new parameter out front).