TC39 Decorators 정식 지원
TypeScript 5.0부터 TC39 Stage 3 Decorators가 정식 지원됩니다. 기존 experimental decorators와 문법이 다릅니다.
function logged(target: any, context: ClassMethodDecoratorContext) {
return function (...args: any[]) {
console.log(`Calling ${String(context.name)}`);
return target.apply(this, args);
};
}
class MyClass {
@logged
greet() { return "hello"; }
}const Type Parameters
function createTuple(...args: T): T {
return args;
}
const tuple = createTuple(1, "hello", true);
// type: readonly [1, "hello", true]
댓글 0