ellamaolson / ngMigration-Assistant

An analysis tool to determine which migration path from AngularJS to Angular is right for you.
198 stars 24 forks source link

AngularJS Component decorators not recognized #9

Closed kfeinUI closed 5 years ago

kfeinUI commented 5 years ago

There are a number of libraries offering Angular-style @Component() decorators and are very helpful tools in preparing for the migration. These could easily be factored into the component count. Since this tool handles hybrid apps, the trick is to be able to distinguish between the Angular and AngularJS flavors. I suggest testing for the the decorator along with the absence of the @angular/core import.

ellamaolson commented 5 years ago

Great suggestion @kfeinUI. Can you elaborate on testing for the decorator and provide an example?

kfeinUI commented 5 years ago

https://github.com/vsternbach/angular-ts-decorators https://github.com/ngParty/ng-metadata

I believe there are others too. Wouldn't worry about their details. Just that they offer a similar @Component() decorator. We just need to check if the decorator is present and that it is not the @angular/core flavor.

These are syntactical sugar for generating a component definition. It does not register that component with the module. Modules also have an Angular-style decorator that accepts your component under its declarations. Great way to get your code shaped much closer to Angular. Way more elegant too even if you're not taking the leap. Surprising that Angular folks and community in general doesn't mention these tools more often.