xxxxxxxxxx
function add(a: number, b: string, c:boolean): string {
return a + b;
}
type AddReturnType = Parameters<typeof add>;
// type AddReturnType = [a: number, b: string, c:boolean];
xxxxxxxxxx
//parameter
type Parameter<T extends (args: any[]) => any> = T extends (args: infer P) => any ? P : never;
type paraMeterCheck = Parameter<(a: string, b: string) => void>;
xxxxxxxxxx
// non typed function
function add(x, y) {
return x + y;
}
// typed function
function add(x: number, y: number): number {
return x + y;
}
// types can be found here: https://www.typescriptlang.org/docs/handbook/basic-types.html