Skip to content

Not working when some property of the class has a Decorator #44

Description

@mribichich

If your class has a Decorator, then the plugin skips the transformation.

It works for everything else. Tested changing the /* @ngInject */ comment to different places.

I'm using babel 7

class DashboardController {
/* @ngInject */
  constructor(
    private $q: ng.IQService,
    private attendanceEventService: IAttendanceEventService,
    private caseService: CaseService,
    private holidayService: HolidayService,
    private attendanceService: IAttendanceService,
    private employeeService: EmployeeService
  ) {
  }

  @AuthorizeDecorator.authorize(['getSomething'])
  getSomething() {
    ...
  }
}

This is the output from babel:

var dashboard__dec, dashboard__class;

function dashboard__applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
  var desc = {};
  Object['ke' + 'ys'](descriptor).forEach(function(key) {
    desc[key] = descriptor[key];
  });
  desc.enumerable = !!desc.enumerable;
  desc.configurable = !!desc.configurable;
  if ('value' in desc || desc.initializer) {
    desc.writable = true;
  }
  desc = decorators.slice().reverse().reduce(function(desc, decorator) {
    return decorator(target, property, desc) || desc;
  }, desc);
  if (context && desc.initializer !== void 0) {
    desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
    desc.initializer = undefined;
  }
  if (desc.initializer === void 0) {
    Object['define' + 'Property'](target, property, desc);
    desc = null;
  }
  return desc;
}

let DashboardController = (dashboard__dec = identity[b].authorize(['getSomething']), (
  dashboard__class = class DashboardController {
    /*@ngInject*/
    constructor($q, attendanceEventService, caseService, holidayService, attendanceService, employeeService) {
      this.$q = $q;
      this.attendanceEventService = attendanceEventService;
      this.caseService = caseService;
      this.holidayService = holidayService;
      this.attendanceService = attendanceService;
      this.employeeService = employeeService;
    }

    getSomething() {
      // ...
    }

  }, (dashboard__applyDecoratedDescriptor(dashboard__class.prototype, 
    \"getSomething\", 
    [dashboard__dec], 
    Object.getOwnPropertyDescriptor(dashboard__class.prototype, \"getSomething\"), 
    dashboard__class.prototype)), dashboard__class));

thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions