-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for tsconfig.json files #1692
Conversation
This allows
Why is the entire file ignored instead of just the |
@Arnavion I agree, we should probably disallow Regarding your second question, I'd like to do what you suggest, but I wonder about this scenario: Say you have directories c:\src\foo and c:\src\bar, each containing a tsconfig.json, and that the current directory is c:\src\foo. Now if you say |
That makes sense. You could expect it to use the tsconfig.json based on the file being compiled ( One alternative is:
It'll probably be more common for all the individual files being compiled to be in the same project, so this approach would allow them to be compiled with that project file. On the other hand it's more complicated, and expensive if the files are in multiple directories. Then again, this might not even be really necessary. The use case I was imagining was that someone makes a change to only a few files of a large project and wants to recompile those files, but perhaps they'd be okay with just compiling the whole project every time. Or they could use automation like I guess the current behavior is fine. |
I am thinking why would anyone want to have Perhaps an |
+1 for the exclude behavior. One question: can I combine regular command line options with the -p option E.g. tsc -p src -module "commonjs" If you share code between the browser and nodejs and you need to compile the code once for commonjs and once for amd it would make sense to only maintain one tsconfig.json file. |
@NoelAbrahams I think there are two important scenarios: (1) Let me drop an empty tsconfig.json file in a directory and have everything in there be a project, and (2) let me describe the exact list of files I want included. The current design covers both with a minimum of complexity. That said, I can certainly see how an @dbaeumer Yes, you can combine other command line options with |
Honestly if your target is editor I would prefer that this feature never make it to master. If those configuration files are implemented, I will have to support them, if I want to offer more complex configuration mechanisms, I will have to support another config file and figure when a file configuration has precedence over another. |
I agree with @fdecampredon that this PR might not be a good idea for IDE developers. Nevertheless
No. Better to have |
@basarat Anders mentioned that already:
The problem with supporting globbing is that it needs to be an own-implementation, since tsc can't rely on node modules. This is why the previous PR for wildcards was abandoned. |
@Arnavion sorry. Thanks! |
What's wrong with As I see it:
|
@NoelAbrahams There are actually two very real needs for
Yes, you can cover those with |
@ahejlsberg, Ah! I failed to spot the potential for including references. The only objection I have is to the following:
In the project structure we have, all files are included in the compilation, including subdirectories. But certainly, I would like to see ordering and referencing to be part of this. |
@ahejlsberg, this fails hard if you have a loop in your file system and
This is mostly a problem if we let others consume this functionality. |
Just to clarify my point above. We would like to make use of the external file reference and ordering feature introduced by This introduces a maintenance problem: every time a new file is added or an existing file deleted If this change is accompanied by associated changes to the tooling (i.e. in Visual Studio for instance the "Add file" feature should automatically update |
@NoelAbrahams perhaps solvable by a third party tool : support a |
@basarat, that is an option. But I would prefer the syntax be simple. We expect to have 40+ Perhaps |
@NoelAbrahams isn't this already take care of by (see original PR comments):
|
🎉 🎊 |
@basarat we would interested to hear how grunt-TS would be using this and if there are any changes on the compiler side you would need |
Any information yet in which release this will be available? (incl. VS-support?) |
This will be in the 1.5 release. Not sure yet what level of VS support we'll have in that release. |
I've added a JSON Schema for this format on http://json.schemastore.org/tsconfig |
@madskristensen cool. But its incomplete. Complete list (I think): https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/tsconfig/tsconfig.ts#L12-L37 I also wrote a simple validator : https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/tsconfig/tsconfig.ts#L40-L68 |
@basarat Awesome. Thanks. Are you sure all those options are supported in |
I assumed so. Considering they added Pinging @mhegazy for an exact answer.
Your best bet : for an up to date list: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L7-L175 |
Thanks for the link to the |
thanks @madskristensen, experimental switches are not guaranteed to work, and can be removed. so i would not add them to the schema. |
Thanks, I've removed the experimental options |
Is
equivalent to
?
|
No. It must point to a file. No gobbing support yet. Requested here : #1927 |
Is there a reason that the |
I think it's a bit silly to disallow globs because a small percentage of use-cases would not work, when the majority of use-cases need it. |
The use for filesGlob is so great - to do exclusions of the node_modules and other dirs, which cause tsc to choike. VSCode is crippled without this. |
More details can be found at: https://github.com/Microsoft/TypeScript/wiki/tsconfig.json |
sigh I wish that: a) The web community would unify on adopting a I think it's really unfortunate this idea was implemented in this way. 😢 |
Isn't that what the.{file} notation is for. Files that are hidden and special.What's wrong with having .gitignore, .vscode, .tsconfig. they all target different purposes. |
This PR implements #1667 with some modifications.
The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project. A project is compiled in one of the following ways:
-project
(or just-p
) command line option that specifies the path of a directory containing a tsconfig.json file.When input files are specified on the command line, tsconfig.json files are ignored.
An example tsconfig.json file:
The
"compilerOptions"
property can be omitted, in which case the compiler's defaults are used.If no
"files"
property is present in a tsconfig.json, the compiler defaults to including all files the containing directory and subdirectories. When a"files"
property is specified, only those files are included.A tsconfig.json file is permitted to be completely empty, which compiles all files in the containing directory and subdirectories with the default compiler options.
Compiler options specified on the command line override those specified in the tsconfig.json file.