Distributing a library with es6-* deps without requiring users to install typings #6950
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
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 thetypings
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:
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 bytypings search
but that has versioning issues. It should probably instead be done by splittinglib.es6.d.ts
in the TypeScript distro into smaller files, then the option"typingDeps":["XXX"]
causes reference tolib.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 onangular2
)--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"]
The text was updated successfully, but these errors were encountered: