-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Please provide an option for combining only declaration files #192
Comments
This would be better handled a post-build step, or as a feature in a larger build system. The set of compiler switches is intentionally small since we'd rather have specific build tools handle more complex scenarios (see https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals). |
When there are sub-folders in the Visual Studio project, setting "Redirect JavaScript output to directory" recreates the folder structure under the output directory. In this situation it's not trivial to combine the declarations (because copy *.d.ts myDeclartions.d.ts is not recursive), and it's necessary to resort to a powershell script or similar. Admittedly, this is not a big deal but when dealing with a large number of projects this is yet another maintenance issue. Here is a suggestion that circumvents having to add another compiler flag, and is also largely backward compatible. The -- out foo.js // Only combine JavaScript output into a single file
-- out foo.d.ts // Only combine declarations into a single file
-- out foo.js|bar.d.ts // Combine both JavaScript and declarations Please consider reopening this issue. |
It's not that we want a small number of compiler flags, it's that we want a low complexity of the commadline interface to tsc. We can come back to this if a large proportion of people need this or there's no way to do it in another tool; I don't think either of those are the case right now. |
@RyanCavanaugh, can you please elaborate why the following is not true:
In other words, what tool should I use in Visual Studio to make this work? As I mentioned above, it's necessary to write a PowerShell script, which requires granting execution rights to PS1 scripts on every single workstation on which the code is compiled. |
You could write an MSBuild task, .targets file, use a more complex build system like grunt, or have a post-build script that used something other than Powershell. |
So, for the lack of any sound alternatives (integrating grunt for just this requirement seemed like overkill) we went ahead with the MSBuild option. The implementation turned out to be non-trivial. It was necessary to deal with the following issues:
After solving all these problems unfortunately we happened upon a problem that is insolvable by the MSBuidl task: When So my point is: Considering that every user who has this requirement has to carry out this non-trivial task, and even then not achieve the required result 100%, it makes sense for TypeScript to enable this (potentially trivial) flag. |
@NoelAbrahams what is the limitation on using --out for js output as well? |
@mhegazy, the reason we want the The reason we want the declarations combined into a single file is to be able to reference all the types with a single |
Couldn't you create a single file that is your master set of type references (ie references.d.ts or myTypes.d.ts) and reference that? |
@danquirk, there are two reasons why we didn't want to maintain a master reference file:
However, your suggestion got me thinking and there is in fact a solution to the problem I outlined above, namely
Basically, instead of creating the combined declarations file as consisting of the _content_ of all the declarations files in the output directory, we instead create it by inserting |
Hi,
We have this particular use-case.
Say we have two projects: MyLib.csproj and MyClient.csproj.
For each project we'd like to
This would enable the following
e.g.
At present the "Combine JavaScript output into file" option combines both the JavaScript and the declarations file.
I suggest another check box for "Combine declarations output into file".
Thanks.
The text was updated successfully, but these errors were encountered: