typescript returntype remove promise

The solution for “typescript returntype remove promise” can be found here. The following code will assist you in solving the problem.

type UnPromisifiedObject = {[k in keyof T]: UnPromisify}
type UnPromisify = T extends Promise ? U : T;

async function promise_props}>(obj: T): Promise> {
const keys = Object.keys(obj);
const awaitables = keys.map(key => obj[key]);

const values = await Promise.all(awaitables);
const result = {} as any;

keys.forEach((key, i) => {
result[key] = values[i];
return result as UnPromisifiedObject;

async function main() {
const x = {
company: Promise.resolve(“company”),
page: Promise.resolve(1)
const res = await promise_props(x);
const company = res.company; // company is a string here
const page = res.page; // page is a number here

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in