Q: Typescript decorator: get class decorator value from method decorator I have a class decorator (fooAnnotation) and method decorator (barDecorator).
import 'reflect-metadata';

function fooAnnotation(value: string){
  console.log('fooAnnotation init...');
  return (target: any): void => {
    console.log('fooAnnotation called...');
    Reflect.defineMetadata('fooAnnotation', value, target);
  };
};

function barAnnotation(value: string){
  console.log('barAnnotation init...');
  return (target: any, propertyKey: any): void => {
    console.log('barAnnotation called...');
    Reflect.defineMetadata('barAnnotation', value, target);
    ...
    const fooAnnotationValue = Reflect.getMetadata('fooAnnotation', target);

   // :( fooAnnotationValue is undefined!!!
  };
};



@fooAnnotation('fooAnnotationValue')
class Foo{

 @barAnnotation('barAnnotationValue')
 public bar: string;
}

My need is that barAnnotation must use the value of fooAnnotation, but unfortunately typescript evaluates class decorators after method decorators, so inside barAnnotation the fooAnnotationMetadata is not defined yet.
How can a method decorator retrieve the value of class decorator?

A: Because the Class Decorator has been executed at the end of class declaration.  So, change your mind, you should store something in the property decorator, and process all in the class decorator.
const innerTempPropsName = '__TempProperties__';

function fooAnnotation(value: string){
  console.log('fooAnnotation init...');
  return (ctor: any): void => {
    console.log('fooAnnotation called...');
    Reflect.defineMetadata('fooAnnotation', value, target);
    const vProps = ctor[innerTempPropsName];
    // now process the vProps...
    delete ctor[innerTempPropsName];
  };
};

function barAnnotation(value: string){
  console.log('barAnnotation init...');
  return (ctorPrototype: any, propertyKey: any): void => {
    console.log('barAnnotation called...');
    const ctor = ctorPrototype.constructor;
    let vProps = ctor[innerTempPropsName];
    if (!vProps) ctor[innerTempPropsName] = vProps = {};
    // store temp properties into vProps
    // vProps[propertyKey] = {value, }
    Reflect.defineMetadata('barAnnotation', value, target);
    ...
  };
};



@fooAnnotation('fooAnnotationValue')
class Foo{

 @barAnnotation('barAnnotationValue')
 public bar: string;
}

