Skip to content
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

Closed
wants to merge 64 commits into from

Conversation

weswigham
Copy link
Member

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 to oldname_### 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).

@ffMathy
Copy link

ffMathy commented Jan 6, 2016

Any status on this?

@jamiewinder
Copy link

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.

@gulbanana
Copy link

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.

@shanewho
Copy link

shanewho commented Feb 8, 2016

I'd really like to have this. 👍

@kamranayub
Copy link

This has been open for almost a year, would be great to finish this off--looking to use this right away ;)

@mhegazy
Copy link
Contributor

mhegazy commented May 22, 2017

This is fairly stale by now. closing.

@mhegazy mhegazy closed this May 22, 2017
@gulbanana
Copy link

:(

@rossipedia
Copy link

screw that, I need this. I'll take it over if @weswigham is done with it

@weswigham
Copy link
Member Author

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)?

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants