Skip to content
On this page

TypeScript Mapped Type

On this page

Mapped Type (맵드 타입)

type Heroes = 'Hulk' | 'Capt' | 'Thor';
type HeroAges = { [K in Heroes]: number }; // 아래와 같이 새 타입이 된다.
type HeroAges = {
Hulk: number;
Capt: number;
Thor: number;
};
const ages: HeroAges = {
Hulk: 100,
Capt: 23,
Thor: 123,
};

reference

LINKS TO THIS PAGE

Edit this page
Last updated on 5/11/2022