Why we say decorators in TypeScript? Why not Annotation(like Java) or Attributes(like C#)?

It's because they do different things.

An annotation adds metadata to a piece of code that can later be read and used by other code. While a decoration decorates some code with some other code.

Take the case of logging.

A logging annotation can be retrieved at runtime by the logger (maybe via reflection) and logging will be generated according to it.

A logging decoration will surround the logged code with a function that logs information.


Annotations in Java are metadata attached to class, methods etc.

However decorators in TypeScript are functions which can add metadata but can also add some behavior like logging.

More information: https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Decorators.md