Typescript has Partial<Object> type that helps to make the all fields of object optional.
Is it possible in the same way to create a generic type Promisify<Person> that will change the Person type from:
interface Person {
getName(): string;
getAge(): number;
}
to:
interface PromisifyPerson {
getName(): Promise<string>;
getAge(): Promise<number>;
}
I have an synchronous API described via Typescript interfaces and my goal is to create asynchronous version of API without rewriting the all interfaces what I have. This is another example:
interface ApplicationApi {
startApp(): void;
readFile(fileName): string;
}
type AsyncApplicationAPI = Async<ApplicationApi>
after that I expect that AsyncApplicationAPI should be something like:
interface AsyncApplicationApi {
startApp(): Promise<void>;
readFile(fileName): Promise<string>;
}