IT/typescript
[Typescript] Parameters<Type>
내일은교양왕
2024. 3. 11. 22:48
개념
함수의 파라마터의 Type을 Type으로 사용하고 싶을 때
function f1(arg: {a:number; b:string}) {
}
type T1 = Parameters<typeof f1>
/**
*
* [arg: { a:number; b:string }]
*
*/
type T2 = Parameters<typeof f1>[0]
/**
*
* { a:number; b:string }
*
*/
https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype
Documentation - Utility Types
Types which are globally included in TypeScript
www.typescriptlang.org