TypeScript 5 새 기능 — satisfies 연산자와 데코레이터 실전 활용
TypeScript 5의 핵심 신기능 완벽 가이드. satisfies 연산자로 타입 안전성 강화, 새로운 데코레이터 표준 구현, const 타입 파라미터, 다중 설정 파일 확장 등 실무에서 바로 쓸 수 있는 코드 예시 포함.
핵심 요약 TypeScript 5.0~5.4의 주요 신기능: ①
satisfies연산자 — 추론 유지하면서 타입 검증 ② 표준 데코레이터 — TC39 Stage 3 표준 준수, 메타데이터 지원 ③const타입 파라미터 — 리터럴 타입 추론 강화 ④ 다중 tsconfig 확장 ⑤ enum·namespace 개선. 실무에서 가장 파급력 큰 기능은satisfies와 새 데코레이터.
TypeScript 5 개요
| 항목 | 값 |
|---|---|
| 주요 신기능 | satisfies 연산자, 표준 데코레이터, const 타입 파라미터, 다중 tsconfig 확장, enum·namespace 개선 |
| 실무에서의 파급력 큰 기능 | satisfies, 새 데코레이터 |
| 주요 버전 시작일 | 2023년 3월 |
TypeScript 5는 2023년 3월부터 시작된 주요 버전으로, 5.0~5.4까지 여러 마이너 업데이트가 누적되어 있습니다. 이 버전에서 가장 중요한 변화는 표준 데코레이터와 satisfies 연산자의 도입입니다.
버전별 주요 출시 일정:
| 버전 | 출시 | 주요 기능 |
|---|---|---|
| TypeScript 5.0 | 2023-03 | satisfies, const 타입 파라미터, 다중 tsconfig 확장 |
| TypeScript 5.1 | 2023-06 | getter/setter 독립 타입, JSX 개선 |
| TypeScript 5.2 | 2023-08 | using/await using 키워드, 데코레이터 메타데이터 |
| TypeScript 5.3 | 2023-11 | Import Attributes, 타입 좁히기 개선 |
| TypeScript 5.4 | 2024-03 | NoInfer 유틸리티, 클로저 타입 좁히기 보존 |
1. satisfies 연산자 — 실전 완전 정복
satisfies 연산자는 TypeScript 5.0에서 도입된 가장 혁신적인 기능 중 하나입니다. 기존 타입 단언의 한계를 넘어 타입 추론을 유지하면서 타입 제약을 검증합니다.
기존 문제점
// ❌ 기존 방식의 문제
type Color = "red" | "green" | "blue";
type ColorMap = Record<string, string | number[]>;
// as 단언: 타입 검증 O, 추론 X
const palette = {
red: [255, 0, 0],
green: "#00ff00",
blue: [0, 0, 255]
} as ColorMap;
// 이제 palette.red는 string | number[] 로 추론됨
// .map()을 쓰려면 타입 단언 필요
palette.red.map(x => x); // 오류! string | number[]에 map 없음satisfies 활용
// ✅ satisfies 연산자
type Color = "red" | "green" | "blue";
type ColorMap = Record<Color, string | number[]>;
const palette = {
red: [255, 0, 0],
green: "#00ff00",
blue: [0, 0, 255]
} satisfies ColorMap;
// 이제 타입 검증 O, 리터럴 추론 O
palette.red.map(x => x); // ✅ number[] 유지됨
palette.green.toUpperCase(); // ✅ string 유지됨
const wrong = { purple: "purple" } satisfies ColorMap; // ❌ 오류: "purple"은 Color 아님실전 활용 패턴
패턴 1: API 응답 객체 검증
interface ApiConfig {
baseUrl: string;
timeout: number;
retries: number;
}
// satisfies로 타입 검증 + 정확한 값 추론 유지
const config = {
baseUrl: "https://api.example.com",
timeout: 5000,
retries: 3,
} satisfies ApiConfig;
// config.timeout은 number가 아닌 5000 (리터럴 타입)
type TimeoutType = typeof config.timeout; // 5000패턴 2: 라우트 정의
type Route = {
path: string;
component: React.ComponentType;
auth?: boolean;
};
const routes = [
{ path: "/", component: Home },
{ path: "/dashboard", component: Dashboard, auth: true },
] satisfies Route[];
// routes[0].path는 "/" (리터럴) 유지, Route 검증도 통과패턴 3: 다국어 번역 객체
type TranslationKey = "hello" | "goodbye" | "welcome";
type Translations = Record<TranslationKey, string>;
const ko = {
hello: "안녕하세요",
goodbye: "안녕히 가세요",
welcome: "환영합니다",
} satisfies Translations;
const en = {
hello: "Hello",
goodbye: "Goodbye",
// welcome 누락 → 컴파일 오류 발생! ✅
} satisfies Translations;2. 표준 데코레이터 — TC39 Stage 3 완전 구현
TypeScript 5.0은 오랫동안 사용하던 실험적 데코레이터(experimentalDecorators)와 별개로 TC39 Stage 3 표준 데코레이터를 지원합니다.
핵심 차이점
| 구분 | 실험적 데코레이터 | 표준 데코레이터 (5.0+) |
|---|---|---|
| 활성화 방법 | experimentalDecorators: true | 기본 활성화 (tsconfig 불필요) |
| 표준 준수 | 자체 구현 | TC39 Stage 3 |
| 실행 순서 | 역순 | 정순 |
| 메타데이터 | emitDecoratorMetadata | Symbol.metadata 사용 |
| 함수 지원 | 제한적 | 클래스 전용 |
클래스 데코레이터
// ✅ TypeScript 5 표준 데코레이터
function sealed(target: typeof SealedClass) {
Object.seal(target);
Object.seal(target.prototype);
}
@sealed
class SealedClass {
greet() { return "Hello!"; }
}메서드 데코레이터
function log(target: any, context: ClassMethodDecoratorContext) {
const methodName = String(context.name);
return function (this: any, ...args: any[]) {
console.log(`[${methodName}] 호출됨, 인수:`, args);
const result = target.call(this, ...args);
console.log(`[${methodName}] 반환값:`, result);
return result;
};
}
class Calculator {
@log
add(a: number, b: number): number {
return a + b;
}
}
const calc = new Calculator();
calc.add(1, 2);
// [add] 호출됨, 인수: [1, 2]
// [add] 반환값: 3접근자 데코레이터
function readonly(target: any, context: ClassAccessorDecoratorContext) {
return {
set() {
throw new Error(`${String(context.name)}은 읽기 전용입니다.`);
}
};
}
class Config {
@readonly
accessor version = "1.0.0";
}
const cfg = new Config();
console.log(cfg.version); // "1.0.0"
cfg.version = "2.0.0"; // ❌ 오류 발생데코레이터 메타데이터 (TypeScript 5.2)
// 메타데이터 API 활용
function validate(target: any, context: ClassFieldDecoratorContext) {
context.metadata[context.name] = { required: true };
}
class UserForm {
@validate
name!: string;
@validate
email!: string;
}
// 메타데이터 읽기
const metadata = UserForm[Symbol.metadata];
console.log(metadata); // { name: { required: true }, email: { required: true } }3. const 타입 파라미터
TypeScript 5.0에서 추가된 const 수정자는 제네릭 함수의 타입 추론을 강화합니다.
// ❌ 기존 방식
function identity<T>(value: T): T {
return value;
}
const result = identity(["a", "b", "c"]);
// result: string[] (리터럴 손실)
// ✅ const 타입 파라미터
function identityConst<const T>(value: T): T {
return value;
}
const result2 = identityConst(["a", "b", "c"]);
// result2: readonly ["a", "b", "c"] (리터럴 유지!)실전 활용: 경로 빌더
function createRoute<const Path extends string>(path: Path) {
return { path, url: () => `https://app.example.com${path}` };
}
const homeRoute = createRoute("/");
// homeRoute.path: "/" (리터럴 유지)
const dashRoute = createRoute("/dashboard");
// dashRoute.path: "/dashboard" (리터럴 유지)4. 다중 tsconfig 확장
TypeScript 5.0부터 tsconfig.json의 extends에 배열을 사용할 수 있습니다.
// tsconfig.json
{
"extends": [
"@tsconfig/strictest/tsconfig.json",
"@tsconfig/node18/tsconfig.json",
"./custom.tsconfig.json"
],
"compilerOptions": {
"outDir": "dist"
}
}이전에는 체인 방식으로 여러 파일을 상속해야 했지만, 이제 배열로 한 번에 다중 상속이 가능합니다.
5. using / await using 키워드 (TypeScript 5.2)
자원 관리를 위한 새 키워드로, 자바의 try-with-resources와 유사합니다.
// Symbol.dispose가 있는 객체
cla
---
**참고:** [한국은행 경제통계](https://ecos.bok.or.kr)
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "TypeScript 5 새 기능 — satisfies 연산자와 데코레이터 실전 활용",
"url": "https://millionscode.com/blog/typescript-5-new-features-satisfies-operator-decorators-practical-guide",
"author": {
"@type": "Person",
"name": "MillionsCode",
"url": "https://millionscode.com/about"
},
"publisher": {
"@type": "Organization",
"name": "MillionsCode",
"logo": {
"@type": "ImageObject",
"url": "https://millionscode.com/favicon.svg",
"width": 512,
"height": 512
}
},
"image": {
"@type": "ImageObject",
"url": "https://millionscode.com/og-default.png",
"width": 1200,
"height": 628
},
"dateModified": "2026-05-19"
}
</script>
## 자주 묻는 질문 (FAQ)
### Q1. TypeScript 5에서 가장 중요한 새 기능은 무엇인가요?
A: satisfies 연산자, 표준 데코레이터, const 타입 파라미터가 실무 영향이 큰 기능입니다.
### Q2. satisfies 연산자는 언제 쓰나요?
A: 객체의 구체적 추론은 유지하면서 특정 타입 조건을 만족하는지 검증할 때 사용합니다.
### Q3. satisfies와 as의 차이는 무엇인가요?
A: as는 타입 단언이고 satisfies는 타입 검증이라 잘못된 구조를 더 안전하게 잡아줍니다.
### Q4. TypeScript 5 데코레이터는 기존과 다른가요?
A: 표준 데코레이터는 TC39 흐름을 따르며 기존 experimentalDecorators와 동작 차이가 있습니다.
### Q5. const 타입 파라미터는 왜 유용한가요?
A: 제네릭 함수에서 리터럴 타입 추론을 보존해 더 정확한 타입을 만들 수 있습니다.
### Q6. TypeScript 5 업그레이드 전 확인할 것은?
A: tsconfig, 데코레이터 사용처, 빌드 도구, ESLint, 라이브러리 타입 호환성을 확인하세요.🔧 이 글과 관련된 무료 도구
관련 글
RTX 5070과 RTX 5080을 AI 학습 관점에서 VRAM, Tensor 성능, 전력, 예산, LoRA 활용까지 비교한 실전 구매 가이드입...
ITChatGPT로 부업하는 법 6가지 — 2026 실전 검증 수익화 가이드ChatGPT로 부업하는 법 6가지 — 2026 실전 검증 수익화 가이드을(를) 통해 IT를 빠르게 정리하면 실무 적용 전 체크리스트와 실패 포...
IT2026 ChatGPT vs Claude vs Gemini — AI 챗봇 성능·가격·활용법 비교2026 ChatGPT vs Claude vs Gemini — AI 챗봇 성능·가격·활용법 비교을(를) 통해 IT를 빠르게 정리하면 실무 적용 ...
IT웹사이트 속도 최적화: 2026년 Core Web Vitals 기준 90+ 달성 비법2026년 Core Web Vitals 기준으로 Lighthouse 100점, PageSpeed Insights, Search Console 측...