javascript - TypeScript does not compile correctly -


i downloaded typescript + angularjs example here: http://todomvc.com/examples/typescript-angular/#/

the problem everytime build visual studio seems references don't compile. if run compiler in cmd tsc --out parameter fine. don't unterstand i'm doing wrong here. example uses _all.ts reference file. there wrong that? tried move file root folder or rename didn't work either.

code applicationjs is:

/// <reference path="_all.ts" />    /**   * main todomvc app module.   *   * @type {angular.module}   */  module todos {      'use strict';        var todomvc = angular.module('todomvc', [])              .controller('todoctrl', todoctrl)              .directive('todoblur', todoblur)              .directive('todofocus', todofocus)              .service('todostorage', todostorage);  }

code _all.ts

/// <reference path='js/libs/jquery/jquery.d.ts' />  /// <reference path='js/libs/angular/angular.d.ts' />  /// <reference path='js/models/todoitem.ts' />  /// <reference path='js/interfaces/itodoscope.ts' />  /// <reference path='js/interfaces/itodostorage.ts' />  /// <reference path='js/directives/todofocus.ts' />  /// <reference path='js/directives/todoblur.ts' />  /// <reference path='js/services/todostorage.ts' />  /// <reference path='js/controllers/todoctrl.ts' />  /// <reference path='application.ts' />

compiles visual studio to:

/// <reference path="_all.ts" />  /**   * main todomvc app module.   *   * @type {angular.module}   */  var todos;  (function (todos) {      'use strict';      var todomvc = angular.module('todomvc', [])          .controller('todoctrl', todos.todoctrl)          .directive('todoblur', todos.todoblur)          .directive('todofocus', todos.todofocus)          .service('todostorage', todos.todostorage);  })(todos || (todos = {}));  //# sourcemappingurl=application.js.map

but tsc --out to:

/// <reference path='../../_all.ts' />  var todos;  (function (todos) {      'use strict';        var todoitem = (function () {          function todoitem(title, completed) {              this.title = title;              this.completed = completed;          }          return todoitem;      })();      todos.todoitem = todoitem;  })(todos || (todos = {}));  /// <reference path='../../_all.ts' />  /// <reference path='../../_all.ts' />  /// <reference path='../../_all.ts' />  var todos;  (function (todos) {      'use strict';        /**      * directive places focus on element applied when expression binds evaluates true.      */      function todofocus($timeout) {          return {              link: function ($scope, element, attributes) {                  $scope.$watch(attributes.todofocus, function (newval) {                      if (newval) {                          $timeout(function () {                              return element[0].focus();                          }, 0, false);                      }                  });              }          };      }      todos.todofocus = todofocus;        todofocus.$inject = ['$timeout'];  })(todos || (todos = {}));  /// <reference path="../../_all.ts" />  var todos;  (function (todos) {      'use strict';        /**      * directive executes expression when element applied loses focus.      */      function todoblur() {          return {              link: function ($scope, element, attributes) {                  element.bind('blur', function () {                      $scope.$apply(attributes.todoblur);                  });                  $scope.$on('$destroy', function () {                      element.unbind('blur');                  });              }          };      }      todos.todoblur = todoblur;  })(todos || (todos = {}));  /// <reference path='../../_all.ts' />  var todos;  (function (_todos) {      'use strict';        /**      * services persists , retrieves todos localstorage.      */      var todostorage = (function () {          function todostorage() {              this.storage_id = 'todos-angularjs-typescript';          }          todostorage.prototype.get = function () {              return json.parse(localstorage.getitem(this.storage_id) || '[]');          };            todostorage.prototype.put = function (todos) {              localstorage.setitem(this.storage_id, json.stringify(todos));          };          return todostorage;      })();      _todos.todostorage = todostorage;  })(todos || (todos = {}));  /// <reference path='../../_all.ts' />  var todos;  (function (todos) {      'use strict';        /**      * main controller app. controller:      * - retrieves , persists model via todostorage service      * - exposes model template , provides event handlers      */      var todoctrl = (function () {          // dependencies injected via angularjs $injector          // controller's name registered in application.ts , specified ng-controller attribute in index.html          function todoctrl($scope, $location, todostorage, filterfilter) {              var _this = this;              this.$scope = $scope;              this.$location = $location;              this.todostorage = todostorage;              this.filterfilter = filterfilter;              this.todos = $scope.todos = todostorage.get();                $scope.newtodo = '';              $scope.editedtodo = null;                // 'vm' stands 'view model'. we're adding reference controller scope              // methods accessible view / html              $scope.vm = this;                // watching events/changes in scope, caused view/user input              // if subscribe scope or event lifetime longer controller, make sure unsubscribe.              $scope.$watch('todos', function () {                  return _this.ontodos();              }, true);              $scope.$watch('location.path()', function (path) {                  return _this.onpath(path);              });                if ($location.path() === '')                  $location.path('/');              $scope.location = $location;          }          todoctrl.prototype.onpath = function (path) {              this.$scope.statusfilter = (path === '/active') ? { completed: false } : (path === '/completed') ? { completed: true } : null;          };            todoctrl.prototype.ontodos = function () {              this.$scope.remainingcount = this.filterfilter(this.todos, { completed: false }).length;              this.$scope.donecount = this.todos.length - this.$scope.remainingcount;              this.$scope.allchecked = !this.$scope.remainingcount;              this.todostorage.put(this.todos);          };            todoctrl.prototype.addtodo = function () {              var newtodo = this.$scope.newtodo.trim();              if (!newtodo.length) {                  return;              }                this.todos.push(new todos.todoitem(newtodo, false));              this.$scope.newtodo = '';          };            todoctrl.prototype.edittodo = function (todoitem) {              this.$scope.editedtodo = todoitem;          };            todoctrl.prototype.doneediting = function (todoitem) {              this.$scope.editedtodo = null;              todoitem.title = todoitem.title.trim();              if (!todoitem.title) {                  this.removetodo(todoitem);              }          };            todoctrl.prototype.removetodo = function (todoitem) {              this.todos.splice(this.todos.indexof(todoitem), 1);          };            todoctrl.prototype.cleardonetodos = function () {              this.$scope.todos = this.todos = this.todos.filter(function (todoitem) {                  return !todoitem.completed;              });          };            todoctrl.prototype.markall = function (completed) {              this.todos.foreach(function (todoitem) {                  todoitem.completed = completed;              });          };          todoctrl.$inject = [              '$scope',              '$location',              'todostorage',              'filterfilter'          ];          return todoctrl;      })();      todos.todoctrl = todoctrl;  })(todos || (todos = {}));  /// <reference path='js/libs/jquery/jquery.d.ts' />  /// <reference path='js/libs/angular/angular.d.ts' />  /// <reference path='js/models/todoitem.ts' />  /// <reference path='js/interfaces/itodoscope.ts' />  /// <reference path='js/interfaces/itodostorage.ts' />  /// <reference path='js/directives/todofocus.ts' />  /// <reference path='js/directives/todoblur.ts' />  /// <reference path='js/services/todostorage.ts' />  /// <reference path='js/controllers/todoctrl.ts' />  /// <reference path='application.ts' />  /// <reference path="_all.ts" />  /**  * main todomvc app module.  *  * @type {angular.module}  */  var todos;  (function (todos) {      'use strict';        var todomvc = angular.module('todomvc', []).controller('todoctrl', todos.todoctrl).directive('todoblur', todos.todoblur).directive('todofocus', todos.todofocus).service('todostorage', todos.todostorage);  })(todos || (todos = {}));  //test

you need open project properties in visual studio , check option "use references" , point _all

fwiw don't recommend --out : https://github.com/typestrong/atom-typescript/blob/master/docs/out.md


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -