-
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
Definition flattening #5332
Definition flattening #5332
Conversation
Any status on this? |
This would be huge for porting libraries to TypeScript. We have all of the pieces for bundling projects together, but of course the main benefit of TypeScript are the types. Definitely hoping to see this soon, even if only a test version. Quick question; I've been trying to use dts-generator, but it complains if I have external types in my signatures (e.g. returning a JQuery instance) and try to exclude them. By default it also bundles these in with the dts which is not at all desirable. How will this be handled once it is supported by TypeScript? Thanks. |
really looking forward to this feature. in practice modules are bundled together by tools like webpack or browserify regardless of whether they're typescript, but definition bundling will be a unique point that allows supplying a library or package's types alongside it. |
I'd really like to have this. 👍 |
This has been open for almost a year, would be great to finish this off--looking to use this right away ;) |
This is fairly stale by now. closing. |
:( |
screw that, I need this. I'll take it over if @weswigham is done with it |
There's a good chance this can be more elegantly reimplemented using the transform pipeline now that we have that. But was this just closed because it was stale, or because the feature is no longer desired (as a team member never requested a refresh AFAIK)? |
This PR is based on #5090.
In #5090, we enable the concatenate of external modules when
--outFile
is paired with--module
, and can create a concatenated ambient module declaration file to go with it.This PR adds a new command line option,
--optimizationEntrypoint
(please give me better suggestions for the name, because eight syllables seems like too much). When passed alongside--outFile
and--module
, it is used to specify a file which is used as the entrypoint for optimizations to the .d.ts (and later potentially the js).When supplied, it changes the declaration emit so that instead of a collection of ambient modules, it emits a single external module file with all types inlined - no
import
statements remain in the resulting dts file, and only those types which are reachable and visible by the entrypoint file's exported types are included. Name conflicts are handled with a renaming scheme whereby items with the same name get mangled tooldname_###
when inlined. This, IMO, ended up resulting in a nicer dts file when there were many internal conflicts than attempting to partially preserve module structure with fake namespaces (and was substantially easier to emit).