1.1.1 β’ Published 2 years ago
smody-library v1.1.1
π smody util library
μκ°
- μ€λͺ¨λ νλ‘μ νΈμμ μ¬μ©λλ λ²μ© νμ λͺ¨λμ λλ€.
MappedKeyToUnion
,PickType
λ©ν νμ μ μ 곡ν©λλ€.
μ€μΉ
npm install smody-library --save-dev
- μ€ν
MappedKeyToUnion
import { MappedKeyToUnion } from 'smody-library';
const COLOR = {
LIGHT_PURPLE: '#F5F3FF',
PURPLE: '#7B61FF',
DARK_PURPLE: '#7054FE',
} as const;
type AvailablePickedColor = MappedKeyToUnion<typeof COLOR>;
// => type AvailablePickedColor = "#F5F3FF" | "#7B61FF" | "#7054FE";
PickType
import { PickType } from 'smody-library';
type Person = {
name: string;
age: number;
}
type PickedName = PickType<Person, 'name'>
// => PickedName type is string
type PickedAge = PickType<Person, 'age'>
// => PickedAge type is number