{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1754","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1754/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1754/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1754/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1754","id":54999333,"number":1754,"title":"Using the smartIndenter","user":{"login":"fdecampredon","id":864201,"avatar_url":"https://avatars.githubusercontent.com/u/864201?v=3","gravatar_id":"","url":"https://api.github.com/users/fdecampredon","html_url":"https://github.com/fdecampredon","followers_url":"https://api.github.com/users/fdecampredon/followers","following_url":"https://api.github.com/users/fdecampredon/following{/other_user}","gists_url":"https://api.github.com/users/fdecampredon/gists{/gist_id}","starred_url":"https://api.github.com/users/fdecampredon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdecampredon/subscriptions","organizations_url":"https://api.github.com/users/fdecampredon/orgs","repos_url":"https://api.github.com/users/fdecampredon/repos","events_url":"https://api.github.com/users/fdecampredon/events{/privacy}","received_events_url":"https://api.github.com/users/fdecampredon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Question","name":"Question","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-21T10:06:01Z","updated_at":"2015-01-21T17:03:05Z","closed_at":null,"body":"To develop a codemirror mode for typescript, I'm forced to use the indenter independently of the language service, to do so I do : \r\n```\r\nvar sourceFile = ts.createSourceFile(Math.random()+ '.ts', text, ts.ScriptTarget.Latest, Math.random() + '');\r\nvar indent = indenter.getIndentation(position, sourceFile,  {\r\n  IndentSize: options.indentUnit,\r\n  TabSize: options.tabSize,\r\n  NewLineCharacter: '\\n',\r\n  ConvertTabsToSpaces: !options.indentWithTabs\r\n});\r\n```\r\nHowever it constantly error in `getTokenPosOfNode`, apparently it fails to find the sourceFile, after some investigation it seems that some node does not have parent. I had to tranform the obtained sourceFile with : \r\n```\r\nfunction setParents(parent: ts.Node) {\r\n    parent.getChildren().forEach(node => {\r\n        if (!node.parent) {\r\n            node.parent = parent;\r\n        }\r\n        setParents(node);\r\n    })\r\n}\r\n```\r\n\r\nIs there a something in the lifecycle that I should do ? Or is it a bug ?\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/70876550","html_url":"https://github.com/Microsoft/TypeScript/issues/1754#issuecomment-70876550","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1754","id":70876550,"user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T17:03:05Z","updated_at":"2015-01-21T17:03:05Z","body":"@mhegazy or @vladima  ?"}}