{"action":"created","issue":{"url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/290","labels_url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/290/comments","events_url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/290/events","html_url":"https://github.com/johnpapa/angularjs-styleguide/issues/290","id":58538261,"number":290,"title":"LIFT Angular and TypeScript","user":{"login":"rcollette","id":136476,"avatar_url":"https://avatars.githubusercontent.com/u/136476?v=3","gravatar_id":"","url":"https://api.github.com/users/rcollette","html_url":"https://github.com/rcollette","followers_url":"https://api.github.com/users/rcollette/followers","following_url":"https://api.github.com/users/rcollette/following{/other_user}","gists_url":"https://api.github.com/users/rcollette/gists{/gist_id}","starred_url":"https://api.github.com/users/rcollette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcollette/subscriptions","organizations_url":"https://api.github.com/users/rcollette/orgs","repos_url":"https://api.github.com/users/rcollette/repos","events_url":"https://api.github.com/users/rcollette/events{/privacy}","received_events_url":"https://api.github.com/users/rcollette/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-23T03:19:14Z","updated_at":"2015-02-24T03:28:04Z","closed_at":"2015-02-24T03:28:04Z","body":"I am going through your Pluralsight course and attempted to move controller declarations like `angular.module(\"app\").controller(\"PurchaseOrdersController\", PurchaseOrdersController);` above the TypeScript class declaration for the controller.  That results in an error\r\n\r\n```\r\nError: error:areq\r\nBad Argument\r\nArgument 'PurchaseOrdersController' is not\r\n```\r\n(The fact that the stacktrace is lost and, the error message is incomplete and offers no description of what happened, is a separate issue)\r\n\r\nThis is because typescript generated classes are defined as an IIFE assigned to a var.  At the time that the `controller(...)` function is called, the variable holding the reference to the class is not yet defined.\r\n\r\nSo where you can place `controller()` depends on whether you are declaring the controller like:\r\n`function MyController(){}` \r\nor\r\n`var MyController = (function(){\r\nfunction MyController(){}\r\nreturn MyController;}());`\r\n\r\nI am not sure this is so much an issue with the style guide as it is a caveat.\r\n\r\nA bad error message combined with a false presumption that such ordering works in all cases can lead to some wasted debugging time."},"comment":{"url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/comments/75692244","html_url":"https://github.com/johnpapa/angularjs-styleguide/issues/290#issuecomment-75692244","issue_url":"https://api.github.com/repos/johnpapa/angularjs-styleguide/issues/290","id":75692244,"user":{"login":"johnpapa","id":1202528,"avatar_url":"https://avatars.githubusercontent.com/u/1202528?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpapa","html_url":"https://github.com/johnpapa","followers_url":"https://api.github.com/users/johnpapa/followers","following_url":"https://api.github.com/users/johnpapa/following{/other_user}","gists_url":"https://api.github.com/users/johnpapa/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpapa/subscriptions","organizations_url":"https://api.github.com/users/johnpapa/orgs","repos_url":"https://api.github.com/users/johnpapa/repos","events_url":"https://api.github.com/users/johnpapa/events{/privacy}","received_events_url":"https://api.github.com/users/johnpapa/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T03:28:04Z","updated_at":"2015-02-24T03:28:04Z","body":"There is a big difference (as you found out) between these: `function foo() { }` and `var foo = function() {};`\r\n\r\nThat's why I use the former in my style guide and reference in in a few blog posts on why I do this. \r\n\r\nTypescript generates code from TS which is why you see what you see there. When using TS or CS or AS with this style guide I am certain there are differences you must take into account because they do things differently than plain old vanilla JavaScript."}}