Skip to main content

PickByType

PickByType은 객체 타입에서 특정 타입의 값을 가진 프로퍼티만 선택하는 TypeScript 유틸리티 타입입니다.

tip

객체에서 특정 타입(예: string, number, boolean 등)의 값을 가진 프로퍼티만 추출하고 싶을 때 유용합니다.

사용 예시

import { O } from 'utilscript';

interface Model {
name: string;
count: number;
isReadonly: boolean;
isEnable: boolean;
}

type T = O.PickByType<Model, boolean>; // { isReadonly: boolean; isEnable: boolean }

type T2 = O.PickByType<Model, string>; // { name: string }