Visitar URL original
question: why isn't it tslib distributed together with tsc? · Issue #150 · microsoft/tslib · GitHub
Skip to content

question: why isn't it tslib distributed together with tsc? #150

Open

Description

It was a surprise for me I was using tslib indirectly, due to an dependency of another package. When I removed this package, the compilation ceased to build my solution and it took me some time to understand what was going on.

I would expect tslib to be installed together with tsc. On the case this separation makes sense, though, I think tsc could declare it as a peerDependencies, so this would be clearer.

Activity

  1. HolgerJeromin commented on May 20, 2021

    @HolgerJeromin

    tslib is a "reimplementation" of the helper functions used by TS.
    It is used if you do use the tsc option importHelpers.
    Or you use noEmitHelpers with manual adding this code.

    In all other cases typescript compiler will not use the tslib code but add them on top of each js file when needed.

  2. gerardolima commented on May 21, 2021

    @gerardolima
    Author

    hey, Holger Jeromin (@HolgerJeromin), you are obviously correct.

    My point is that I only understood what was going on after re-reading the documentation for importHelpers. Unfortunately, the problem started after removing a package unrelated to tsc and it took me some time to find the error was being caused by this specific compiler option.

    As Npm provides a standard way to ensure packages are present on runtime, using documentation to state "You will need to ensure that the tslib module is able to be imported at runtime" , instead, looks not the best idea to me. It declares what actually should be a dependency in a very fragile way.

    Again, I'd expect all code related to TS-JS transpiling to be injected by tsc without implicit dependencies. We all use TypeScript to provide an automated way to describe and verify the correct way to use code; this wouldn't be necessary if we'd preferred to consult documentation ;)

    Orta Therox (@orta), if you'd think it is correct, please, tag this as a suggestion for improvement.

  3. gerardolima commented on May 21, 2021

    @gerardolima
    Author

    I think this is related to microsoft/TypeScript#37991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions