{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1667","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1667/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1667/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1667/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1667","id":54291409,"number":1667,"title":"Add support for a .tsconfig file ","user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/In+Discussion","name":"In Discussion","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-14T07:14:37Z","updated_at":"2015-01-14T07:43:23Z","closed_at":null,"body":"Typescript compiler lacks a native way of maintaining compilation options and source files for a given compilation unit like a project or a module. Using /// <references> can help ease the problem, but there is still a tax of adding and managing the references and it does not handle the compilation options issue. Moreover, different editors have different ways of representing project or module structure and compilation options which make cross-editor collaboration tricky.\r\n\r\nThe proposal is to introduce a new file `.tsconfig` that marks a compilation unit (aka project or module). The .tsconfig follows the footsteps of the .git* file family. Calling tsc in a directory with a .tsconfig will use the contents of the file and all .ts files in the directory as inputs without the need to specify them on the command line again.\r\n\r\n### .tsconfig in detail\r\n- .tsconfig is a json file\r\n- The presence of a .tsconfig in a directory indicate that all .ts file in this directory and its sub directories recursively are part of the compilation unit\r\n  - .d.ts files generated from the compilation but live within the directory are not included in the compilation unit identified by .tsconfig\r\n- .tsconfig can specify additional compilation settings for the compilation\r\n- Calling tsc in a folder containing .tsconfig will trigger compilation using the config file\r\n- Since .tsconfig is a json file, it can be leveraged by other tools (linters, editors, build tools etc..) to store TS related project configuration\r\n- Example .tsconfig\r\n```JSON \r\n{\r\n    \"compilerOptions\": [\"-t ES5\", \"--out myoutput.js\", \"--noImplicitAny\"],\r\n    \"linterOptions\": {\r\n        \"suppressWarnnings\": [234, 3363] \r\n    }\r\n}\r\n```\r\n\r\n### Module example\r\nConsider the following directory structure:\r\n```\r\nshared/\r\n\tnode.d.ts\r\n\ttools.ts\r\nfoo/\r\n\t.tsconfig\r\n\ta.ts // adds a ///<reference> to node.d.ts \r\n\tb.ts\r\nbar/\r\n\t.tsconfig\r\n\tc,ts // adds a /// <references> to tools.ts\r\n\td.ts\r\n\tbaz/\r\n\t\te.ts\r\n```\r\n\r\nCalling tsc in \"foo\" is equivalent to` tsc a.ts b.ts` \r\nCalling tsc in \"bar\" is equivalent to `tsc c.ts d.ts baz/e.ts`\r\n\r\n### Using .tsconfig with tsc\r\n- When calling tsc with no input files, the following steps are taken:\r\n 1. Find the owning .tsconfig file by walking up the directory structure until a .tsconfig file is found, or the drive root is reached\r\n 2. If a .tsconfig was found, compilation will be triggered with all .ts files in the directory containing the .tsconfig and all its sub directories\r\n 3. The command line switch are compiled with the configuration options from the .tsconfig defining the compilation command line flags (e.g.: `tsc --watch` will cause a tsc to compile the contents of the current project in watch mode)\r\n\r\n- When calling tsc with input a single directory name (e.g.: `tsc compiler`), If the directory contains a .tsconfig at the root, steps 2 and 3 from above are followed.\r\n\r\n### Specifying output order with --out and .tsconfig\r\nwhen using --out, the compiler relies on the order of the files passed on the command line to order the emitted JavaScript code. If using .tsconfig, the compiler will look for a special file `_references.ts` at the root (next to the .tsconfig file), and will ensure that this file is the first file in the list of input files. this implies that /// <reference> tags in _references.ts will specify order of the emitted files.\r\n\r\n### Open issues:\r\n1. Should the tsconfig file have a `.json` extension to indicate intended content, and allow editors to correctly colorize it, format it, etc..\r\n2. In a VS project context (say .csproj), should .tsconfig be honored, or ignored in favor of the project."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/69879706","html_url":"https://github.com/Microsoft/TypeScript/issues/1667#issuecomment-69879706","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1667","id":69879706,"user":{"login":"Arnavion","id":1096010,"avatar_url":"https://avatars.githubusercontent.com/u/1096010?v=3","gravatar_id":"","url":"https://api.github.com/users/Arnavion","html_url":"https://github.com/Arnavion","followers_url":"https://api.github.com/users/Arnavion/followers","following_url":"https://api.github.com/users/Arnavion/following{/other_user}","gists_url":"https://api.github.com/users/Arnavion/gists{/gist_id}","starred_url":"https://api.github.com/users/Arnavion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arnavion/subscriptions","organizations_url":"https://api.github.com/users/Arnavion/orgs","repos_url":"https://api.github.com/users/Arnavion/repos","events_url":"https://api.github.com/users/Arnavion/events{/privacy}","received_events_url":"https://api.github.com/users/Arnavion/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T07:43:23Z","updated_at":"2015-01-14T07:43:23Z","body":"- It would be nice if \"commandLineOptions\" was an object like `{ \"t\": \"ES5\", \"noImplicitAny\": true }` instead of an array of strings (essentially the CompilerOptions interface but with strings instead of enums). This is similar to how the grunt plugin, etc. are configured. See [this](https://www.npmjs.com/package/grunt-typescript#documentation) and [this](https://www.npmjs.com/package/grunt-ts#support-for-tsc-switches).\r\n\r\n- What options should not be honored in a .tsconfig ? For example, I don't know if anyone will ever want \"watch\" to be a default behavior of running tsc under their project directory, so even if .tsconfig contains \"watch\" it should be ignored?"}}