I have a function convert, its parameter is an object, the value can be function or an object contains three properties, the type looks like this.
type Input = {
[K: string]: () => any | { pending: () => any, fulfilled: () => any, rejected: {} => any }
}
I hope can return an object, that the keys will generate by the values, for example:
const result = convert({
sync() {},
async: {
pending() {},
fulfilled() {},
rejected() {}
}
});
// the keys of result
result.sync();
result.asyncPending();
result.asyncFulfilled();
result.asyncRejected();
currently, I know how to generate result by the keys and the string literals
type Result<Input> = {
[key in keyof Input as `${string & key}Fulfilled`]: any
}
but can't meet my requirement, I google for a long time, but can't found the solution.