-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I have a medium-sized project (~15-20k SLOC). It was coded under a tight deadline so there's hardly any tests. Now the the initial deadline to demo it is passed, we can prep it for production. As a first step, rather than write tests for everything, I think there's a lot to be gained by typscripting it first, then adding tests to the most core features as time allows.
I'm at a loss for what style is the best approach. I'm comparing your project to this one. Specifically, this project template seems to go much farther extremes in using the typescript features to rigidify the app.
As a starting point, looking at their app.js, it is far more rigorous. It has functions to register every controller, service, directive etc. This may seem like overkill, but it allows us to use the module pattern in the controllers, as such:
module app.controllers {
export class MyController implements IController {
constructor (private $scope, private myService) {
$scope.message = myService.someMethod();
}
}
}
So What i'm asking is, is santialbo's complexity really necessary? I mean, I like the idea of being very strict everywhere, but on the other hand, I have a lot of js files to convert. I kind of like your hybrid approach where we kind of leave the angulary-parts in vanilla js, but add some type definitions for the $scope and models. I mean, there's not a whole lot to a controller or a directive that really needs type definitions. I'd think it's mainly models and such you want to be sure you can refactor easily.
todomvc.controller('TodoCtrl', function TodoCtrl($scope:TodoCtrlScope, $routeParams:TodoCtrlRouteParams, todoStorage:TodoStorage, filterFilter) {
var todos = $scope.todos = todoStorage.get();
...
I just don't want to shoot my self in the foot and not get the "strictness" I crave. Maybe this is a weird question, but I'm a TS noob. In santialbo's example app.js do I need those module registrations to declare controllers as he does? If I understand correctly, his example app tries to make first-class typescript objects/classes/modules out of the boilerplate angular objects, is this correct?
great intro vid, btw.