{"action":"created","issue":{"url":"https://api.github.com/repos/domchen/typescript-plus/issues/7","repository_url":"https://api.github.com/repos/domchen/typescript-plus","labels_url":"https://api.github.com/repos/domchen/typescript-plus/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/domchen/typescript-plus/issues/7/comments","events_url":"https://api.github.com/repos/domchen/typescript-plus/issues/7/events","html_url":"https://github.com/domchen/typescript-plus/issues/7","id":247606961,"number":7,"title":"得到ts排序的接口有公开么？","user":{"login":"ydcoming","id":3353702,"avatar_url":"https://avatars3.githubusercontent.com/u/3353702?v=4","gravatar_id":"","url":"https://api.github.com/users/ydcoming","html_url":"https://github.com/ydcoming","followers_url":"https://api.github.com/users/ydcoming/followers","following_url":"https://api.github.com/users/ydcoming/following{/other_user}","gists_url":"https://api.github.com/users/ydcoming/gists{/gist_id}","starred_url":"https://api.github.com/users/ydcoming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ydcoming/subscriptions","organizations_url":"https://api.github.com/users/ydcoming/orgs","repos_url":"https://api.github.com/users/ydcoming/repos","events_url":"https://api.github.com/users/ydcoming/events{/privacy}","received_events_url":"https://api.github.com/users/ydcoming/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-03T06:41:30Z","updated_at":"2017-08-04T02:58:06Z","closed_at":null,"body":"<!-- BUGS: Please use this template. -->\r\n<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:**  2.2.1 / nightly (2.2.0-dev.201xxxxx)\r\n\r\n**Code**\r\n\r\n```ts\r\n// A *self-contained* demonstration of the problem follows...\r\n\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n**Actual behavior:**\r\n"},"comment":{"url":"https://api.github.com/repos/domchen/typescript-plus/issues/comments/320143438","html_url":"https://github.com/domchen/typescript-plus/issues/7#issuecomment-320143438","issue_url":"https://api.github.com/repos/domchen/typescript-plus/issues/7","id":320143438,"user":{"login":"domchen","id":6849001,"avatar_url":"https://avatars3.githubusercontent.com/u/6849001?v=4","gravatar_id":"","url":"https://api.github.com/users/domchen","html_url":"https://github.com/domchen","followers_url":"https://api.github.com/users/domchen/followers","following_url":"https://api.github.com/users/domchen/following{/other_user}","gists_url":"https://api.github.com/users/domchen/gists{/gist_id}","starred_url":"https://api.github.com/users/domchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domchen/subscriptions","organizations_url":"https://api.github.com/users/domchen/orgs","repos_url":"https://api.github.com/users/domchen/repos","events_url":"https://api.github.com/users/domchen/events{/privacy}","received_events_url":"https://api.github.com/users/domchen/received_events","type":"User","site_admin":false},"created_at":"2017-08-04T02:58:06Z","updated_at":"2017-08-04T02:58:06Z","body":" ## 命令行方式\r\n\r\n开启reorderFiles参数后，再在命令行加上参数--listFiles，就会从控制台打印出排序后的文件列表。\r\n\r\n## 编程方式\r\n\r\n排序的模块是独立的接口, 引用typescript.d.ts 就行\r\n\r\n```\r\ndeclare namespace ts {\r\n    interface SortingResult {\r\n        sortedFileNames: string[];\r\n        circularReferences: string[];\r\n    }\r\n    function reorderSourceFiles(program: Program): SortingResult;\r\n}\r\n\r\n```\r\n具体如何编程方式调用tsc，需要先去参考ts官方的API使用文档：[Using the Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API), 根据那边的文档构建出一个program对象，然后调用对program对象调用一次 ts.reorderSourceFiles(), 打印返回结果SortingResult.sortedFileNames 就行了。这部分的调用代码也可以参考本项目里 src/compiler/tsc.ts 内的compile() 函数内容。"}}
{"actor":{"display_login":"domchen"}}