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

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

Open
gerardolima opened this issue May 20, 2021 · 3 comments
Open

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

gerardolima opened this issue May 20, 2021 · 3 comments
Labels

Comments

@gerardolima
Copy link

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.

@HolgerJeromin
Copy link

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.

@orta orta added the question label May 20, 2021
@gerardolima
Copy link
Author

gerardolima commented May 21, 2021

hey, @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, if you'd think it is correct, please, tag this as a suggestion for improvement.

@gerardolima
Copy link
Author

I think this is related to microsoft/TypeScript#37991

Azlond pushed a commit to godmodelabs/tslib that referenced this issue Aug 19, 2021
Azlond pushed a commit to godmodelabs/tslib that referenced this issue Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants