Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Get Promise type TypeScript

//return from promise
type promiseReturn<T extends Promise<unknown>> = T extends Promise<infer type>
	? type extends Promise<unknown>
		? promiseReturn<type>
		: type
	: never;
type prom = promiseReturn<Promise<string>>; //string
type prom_2 = promiseReturn<Promise<Promise<string>>>; //string
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Get #Promise #type #TypeScript
ADD COMMENT
Topic
Name
3+5 =