Hiprup

What is the difference between annotations and decorators in Angular?

Two ways to add metadata in JavaScript/TypeScript ecosystems. Angular uses decorators exclusively in modern code.

Decorators — TypeScript syntax (@Decorator); functions executed at runtime that modify or annotate the target. Standard in modern Angular.

Annotations — older AngularJS-era pattern; metadata stored as a static property on the class. Survived briefly during Angular 2 alpha; gone now.

  • Both attach metadata — the framework reads it to know how to use the class.

  • Decorators are language-level — part of TypeScript / Stage 3 ECMAScript; tooling supports them widely.

  • In practice — you only ever write decorators in Angular today; the term “annotation” appears in older Angular 2 docs.

Annotations were AtScript's passive metadata array; decorators are TS functions that actively receive and modify the target. Modern Angular uses decorators only — annotations are dead history.

What is the difference between annotations and decorators in Angular? | Hiprup