How does Typescript: get the return type of a generic function?

suppose I have an interface and a generic function

const unused = foo<number>()
declare const a: typeof unused
// a: SimpleRecord<number>[]

but a function call will be triggered. If foo has side effects, it will get rid of.

so ask me, how exactly can I achieve type ret < T > = ReturnType < typeof foo < T > ?

Mar.24,2021

declare function foo<T>():T[];

return generics? I think your problem description is a little confused.
just say your input and expected output


interface SimpleRecord<T> { prop: T }

type Foo<T> = () => SimpleRecord<T>[];

declare function foo<T>(): ReturnType<Foo<T>>;

let a: ReturnType<Foo<string>>;
//a: SimpleRecord<string>[]

I don't know if this is what you want

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e545bd-452c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e545bd-452c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?