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

Distributing a library with es6-* deps without requiring users to install typings #6950

Closed
alexeagle opened this issue Feb 7, 2016 · 4 comments
Assignees
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@alexeagle
Copy link
Contributor

Had a ts-typings slack conversation with @mhegazy just now, regarding angular2 changing our typings to stop polluting the type-checker with our dependencies.
(details on that change: https://docs.google.com/document/d/1vgepQPkuHS4P3rzANQpoMIDIXe0Rl9Z2QyTtb8dpMoI/edit# )

While correct, this makes the getting started experience worse for Angular 2 users (many of whom are new to TypeScript and even JavaScript).

The major stumbling block is our dependency on es6-promise and es6-collections. For users with --target=es5 (the majority and default case), they need these two .d.ts files presented to the compiler. When --target=es6, we must avoid Duplicate identifier errors. We would prefer not to have the typings tool involved in our first five minutes, since we may lose some audience from the complexity and possibility of a mistake ruining their first app.

To make it really seamless we need two things:

  • If the user has a dependency on angular2, we want the compiler to add es6-promise and es6-collections typings. Imagine if angular2/package.json could declare "ambientTypingsDependencies": ["es6-promise","es6-collections"]. (We don't care what the right-hand side means - it could mean any typing discoverable by typings search but that has versioning issues. It should probably instead be done by splitting lib.es6.d.ts in the TypeScript distro into smaller files, then the option "typingDeps":["XXX"] causes reference to lib.XXX.d.ts and this does not become a general-purpose mechanism. This is really similar to --target=es5+es6-promise+es6-collections except that the user doesn't need to specify it, rather it appears via the dependency on angular2)
  • No Duplicate identifier errors based on the --target setting. This could be either a fix for New APIs added to lib.d.ts may break client codes. Allow duplicated members in interfaces? Make lib.d.ts overridable? #3215, or else avoiding the addition of those typings for --target=es6, maybe with something like "typingsDependencies__ButEs5Only": ["es6-promise","es6-collections"]
@alexeagle
Copy link
Contributor Author

Another detail here: you should start putting together the parts of lib.es7.d.ts - we should be able to depend on es7-reflect-metadata this way rather than an external channel for distribution.

cc @IgorMinar

@mhegazy
Copy link
Contributor

mhegazy commented Feb 19, 2016

Just a quick note, it is not ES7/ES2016 now. Only proposals at stage 4 can make it to the ES7 train at this point, so it is got to be ES8+.

@mhegazy mhegazy added Suggestion An idea for TypeScript In Discussion Not yet reached consensus @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped labels Feb 19, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Jul 21, 2016

Should be addressed by #9851

@RyanCavanaugh
Copy link
Member

This is implemented as much as we know how to with /// <reference lib= directives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

3 participants