Type Safe Decorators in TypeScript

Опубликовано: 31 Май 2026
на канале: Slaven Ivanov
2,267
73

Add type safety to TypeScript decorators with a simple addition. TypedPropertyDescriptor is applied to the decorator factory to ensure type safety. In this example we explore an example where we constrict our decorator to be applied to only async functions. This can easily be extended to allow the decorator to be applied to functions with a specific input or output. Like a function that takes in two numbers and returns their sum as a string.