Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport for tsconfig.json files #1692
Conversation
ahejlsberg
added some commits
Jan 15, 2015
msftclas
added
the
cla-not-required
label
Jan 16, 2015
This comment has been minimized.
This comment has been minimized.
|
This allows
Why is the entire file ignored instead of just the |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
This is pretty gross for the negated cases. I'd rather we just use a helper function. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
NoelAbrahams
commented
Jan 16, 2015
I am thinking why would anyone want to have Perhaps an |
This comment has been minimized.
This comment has been minimized.
|
+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. |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
Looks like when JSON config is used, any *.ts file sitting next to it is automatically included in the build. Why is that? Handling of a config doesn't seem to be much related to a particular behaviour of scanning directories. |
This comment has been minimized.
This comment has been minimized.
fdecampredon
commented
Jan 17, 2015
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. |
This comment has been minimized.
This comment has been minimized.
|
I agree with @fdecampredon that this PR might not be a good idea for IDE developers. Nevertheless
No. Better to have |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@Arnavion sorry. Thanks! |
This comment has been minimized.
This comment has been minimized.
NoelAbrahams
commented
Jan 18, 2015
|
What's wrong with As I see it:
|
This comment has been minimized.
This comment has been minimized.
|
@NoelAbrahams There are actually two very real needs for
Yes, you can cover those with |
This comment has been minimized.
This comment has been minimized.
NoelAbrahams
commented
Jan 18, 2015
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
NoelAbrahams
commented
Jan 19, 2015
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@NoelAbrahams perhaps solvable by a third party tool : support a |
This comment has been minimized.
This comment has been minimized.
|
Shouldn't --declaration option also be present in the services one? |
This comment has been minimized.
This comment has been minimized.
lcorneliussen
commented
Feb 2, 2015
|
Any information yet in which release this will be available? (incl. VS-support?) |
This comment has been minimized.
This comment has been minimized.
|
This will be in the 1.5 release. Not sure yet what level of VS support we'll have in that release. |
This was referenced Feb 4, 2015
mhegazy
referenced this pull request
Feb 26, 2015
Closed
Smarter contatenation based on import. #2032
This comment has been minimized.
This comment has been minimized.
madskristensen
commented
Mar 25, 2015
|
I've added a JSON Schema for this format on http://json.schemastore.org/tsconfig |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
madskristensen
commented
Mar 25, 2015
|
@basarat Awesome. Thanks. Are you sure all those options are supported in |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
madskristensen
commented
Mar 25, 2015
|
Thanks for the link to the |
This comment has been minimized.
This comment has been minimized.
|
thanks @madskristensen, experimental switches are not guaranteed to work, and can be removed. so i would not add them to the schema. |
This comment has been minimized.
This comment has been minimized.
madskristensen
commented
Mar 25, 2015
|
Thanks, I've removed the experimental options |
This comment has been minimized.
This comment has been minimized.
Acaspita
commented
Apr 13, 2015
|
Is
equivalent to
?
|
This comment has been minimized.
This comment has been minimized.
No. It must point to a file. No gobbing support yet. Requested here : #1927 |
This comment has been minimized.
This comment has been minimized.
srackham
commented
May 5, 2015
|
Is there a reason that the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Why did this happen? |
This comment has been minimized.
This comment has been minimized.
|
Symlink references can be circular so we'd need to keep track of how many we have traversed and stop at some limit. It would add some complexity, but it is certainly doable. A PR would be welcome if you're so inclined. |
This comment has been minimized.
This comment has been minimized.
|
Could you provide a motivational example of the case when this can happen? I don't quite see how recursive symlinks can emerge in a legitimate codebase, except by mistake. It feels like that should just be an error. And it is by default, here is an example trace when trying to stat a circular symlink:
|
This comment has been minimized.
This comment has been minimized.
robertbaker
commented
Jun 9, 2015
|
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. |
This comment has been minimized.
This comment has been minimized.
httpete
commented
Jul 15, 2015
|
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. |
This comment has been minimized.
This comment has been minimized.
|
More details can be found at: https://github.com/Microsoft/TypeScript/wiki/tsconfig.json |
This comment has been minimized.
This comment has been minimized.
matthew-dean
commented
Jul 30, 2015
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
ahejlsberg commentedJan 16, 2015
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:
{ "compilerOptions": { "module": "commonjs", "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "out": "../../built/local/tsc.js", "sourceMap": true, }, "files": [ "core.ts", "sys.ts", "types.ts", "scanner.ts", "parser.ts", "utilities.ts", "binder.ts", "checker.ts", "emitter.ts", "program.ts", "commandLineParser.ts", "tsc.ts", "diagnosticInformationMap.generated.ts" ] }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.