Skip to content

fix tsconfig.json build target es6 not working issue#6

Merged
Romakita merged 1 commit intotsedio:masterfrom
vincent178:master
Dec 9, 2016
Merged

fix tsconfig.json build target es6 not working issue#6
Romakita merged 1 commit intotsedio:masterfrom
vincent178:master

Conversation

@vincent178
Copy link
Contributor

Thanks for the great project. It helps a lot.

I found an issue when I use tsc compiler compile to target es6, the controller doesn't work.
So I dig in the source code, I found that when compile to es6, the controller class doesn't convert to function style, then the Object.keys(this.targetClass.prototype) always return blank array [].

for example

// compiler target es6 
class UsersController { 

  constructor(templateService, calendarsServer) {
    this.templateService = templateService;
    this.calendarsServer = calendarsServer;
  }

  indexAction(request, response) {
  }

  get index() {
  }

};

// compiler target es5
function UsersController1(templateService, calendarsServer) {
    this.templateService = templateService;
    this.calendarsServer = calendarsServer;
}

UsersController1.prototype.indexAction = function(request, response) {
}

const p1 = UsersController.prototype;
const p2 = UsersController1.prototype;

console.log(p1);
console.log(p2);

console.log(Object.keys(p1).length); // returns 0
console.log(Object.keys(p2).length); // returns 1

I made a PR to fix this using Object.getOwnPropertyNames refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties

Thanks,
Vincent

@coveralls
Copy link

coveralls commented Dec 8, 2016

Coverage Status

Coverage decreased (-0.003%) to 99.365% when pulling f8faee8 on vincent178:master into 5d8a671 on Romakita:master.

@Romakita Romakita merged commit f1afe55 into tsedio:master Dec 9, 2016
@Romakita
Copy link
Collaborator

Romakita commented Dec 9, 2016

Hello Vincent178,

Thanks for your pull request :)
I have remove the ES6 compilation option for the version 1.2 because I had some issues.
I will test a little more ts-express-decorators in future releases ;)

Thanks again 👍
Romain

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants