본문 바로가기
IT/typescript

[Typescript] Parameters<Type>

by 내일은교양왕 2024. 3. 11.

개념

함수의 파라마터의 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