-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Option to copy custom types to outDir #35296
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
Comments
This would also be useful for projects migrating from JavaScript to TypeScript. I want to write custom type declaration files for legacy JavaScript files and output the For example, I have
and
I know I can write JSDoc in my legacy JavaScript files, but I'd much rather write TypeScript declarations and have |
This has started to cause me minor grief because I have to compile unnecessarily. My project is setup as follows.
The I need |
Please see my example repository for a demonstration of the issue. |
By the way, the purpose of including custom type definition files is not only for compiled tests in the same project, but for down-stream consumers of the package as well. |
Search Terms
declaration files, .d.ts, ergonomics, distributable package, library, compiler option
Suggestion
I would like
tsc
to include an option that enables copying.d.ts
files from my project's source tree into the configuredoutDir
.Use Cases
I maintain a distributable library that is often used as a dependency of other packages. As often as I can, I depend on
@type/*
packages and the core type libraries to express the types in the platforms that my library supports.However, there are cases where these sources do not reflect the ground truth of my supported platforms (for example, old browsers w/ proprietary APIs, or experimental/unstable/nascent web platform features). In these cases, it isn't suitable to upstream my custom types to another package, and even if it was, the latency involved in waiting for upstream contributions to be accepted and published is not a good reason to block a release of my library.
In cases like these, I tend to express the types in
.d.ts
files in my source tree. However, per #5112,tsc
does not copy these files to my configuredoutDir
as a matter of principle. This means that I have to complicate my build with an additional copy step in order to produce a comprehensive, publishable artifact. Meanwhile, it seems liketsc
could make my life a lot simpler by copying over these files on my behalf.Examples
This could manifest in a lot of ways, but a strawperson would be to add a compiler flag. Call it
--include-custom-type-declarations
(or any suitable name).If
tsc
is invoked with this flag set to true, thentsc
will include all.d.ts
declarations in the source tree among the artifacts generated in theoutDir
.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: