Javascript Proposal Decorators Quick Reference

|  Playground |  Tutorial
version

Decorator parameters and return



Class Method Getter Setter Field Accessor
decorator parameters
value the class the method the getter the setter undefined {get, set}
 {
  kind: "class" "method" "getter" "setter" "field" "accessor"
  name: the element name
  access.get() undefined if it is private if it is private undefined if it is private if it is private
  access.set(value) undefined undefined if it is private if it is private if it is private
  isStatic: undefined true if it is a static member
  isPrivate: undefined true if it is a private member
  getMetadata(key) always
  setMetadata(key,value) always
  addInitializer(initalizer) only if it called with @init:
 }
decorator return
 return (optional) new class new method new getter new setter function for the initial value new object with {get, set}

Metadata


Class   MyClass[Symbol.metadata][KEY].constructor
Object member public   MyClass.prototype[Symbol.metadata][KEY].public.name
private   MyClass.prototype[Symbol.metadata][KEY].private
Static public   MyClass[Symbol.metadata][KEY].public.name
private   MyClass[Symbol.metadata][KEY].private
MyClass is the class name
Symbol.metadata is a well know symbol
KEY is the symbol used as key
name is the member name
private is an array with all private members metadata