Typescript 5 decorators
Let’s explore the new decorator standard
TypeScript five has just been released. In this release, TypeScript has implemented the new upcoming ECMA script decorators standard. Let’s take a look.
Wait a minute? Upcoming decorator standard? I have been using TypeScript decorators for years. How was this working so far if the standard isn’t here yet?
--experimentalDecorators
TypeScript has supported experimental decorators for a while, but for it to work, it required the use of a compiler flag called --experimentalDecorators
.
With the latest update, the flag is no longer necessary, and decorators can be used without it.
But hold on; there’s a catch. The type-checking and emission rules have gotten a makeover, so don’t be surprised if your favorite decorators from yesteryear don’t play nicely with the new kids on the block.
No worries, though; the future looks bright, with future ECMAScript proposals promising to bring the decorating party to a new level!
Let’s write our first decorator
Let’s start with a simple OnePieceCharacter
class.
What is One Piece? Well, it’s the greatest anime ever!