jayphelps / core-decorators

Library of stage-0 JavaScript decorators (aka ES2016/ES7 decorators but not accurate) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic.
MIT License
4.51k stars 263 forks source link

suppressWarnings decorator function cannot suppress deprecated decorator function call console.warn output #152

Open xiaofan9 opened 6 years ago

xiaofan9 commented 6 years ago
import { suppressWarnings } from 'core-decorators';

class Person {
  @deprecated
  facepalm() {}

  @suppressWarnings
  facepalmWithoutWarning() {
    console.warn("it is not output"); // not output
    this.facepalm();
  }
}

let person = new Person();

person.facepalmWithoutWarning();
// no warning is logged

The above code actually runs, it will still be able to call console.warn and output the warning, but facepalmWithoutWarning function call console.warn is not output.

image