-
Notifications
You must be signed in to change notification settings - Fork 12.8k
es2020.d.ts is included for a project configured to only use lib:["es5"]
#42827
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
Comments
Just wanted to call out that after digging into the node types history a bit more, seems like the inclusion of lib references has been going on for much longer then I thought. For example |
See also #37053 |
hmmm, @RyanCavanaugh not sure I understand how this is a duplicate of that item. The problem of test types being available in non-test files seems similar but I do not believe it is the same. Were you thinking that the solution to that issue would address this issue as well? |
The "scope pollution" problem occurs in all of these contexts and has the same speculative fix in each place - some way for the transitive dependencies of types packages to not appear in your program. |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about compilerOptions "lib" and "types"
β― Playground Link
Couldn't figure out how to add dependencies in the playground so uploaded an example repository:
https://github.com/greyepoxy/typescript-over-lib-inclusion-issue
π» Code
In a project with the following
tsconfig.json
excerpt,And the following code,
π Actual behavior
Compile succeeds without issue
π Expected behavior
For the compiler to throw an Error because BigInt should not be defined because it is in the es2020 lib which is not included in the compilerOptions
I have done some analysis on why this occurring, please see the root cause section in the example project readme.
Why this Matters
In the company I work for (Tableau), several hundreds of web developers have depended on the tsconfig
lib
as a tool to try and prevent using new JavaScript features that are not present in IE11 (and other slower to update browsers). With the recent change to@types/node
to always include thees2018
and parts of thees2020
lib, there is no way to rely on this compile time check to make sure someone has not started to use a new JavaScript feature unintentionally.Other Related Issues
There seems to be a other "related" issues, but best as I can tell none that discuss this specific problem.
#41999
#18588
There does appear to a proposal that I believe would address this issue https://gist.github.com/RyanCavanaugh/702ebd1ca2fc060e58e634b4e30c1c1c. Not sure if that means other issues have already been created and closed related to this problem. Apologies if they have.
The text was updated successfully, but these errors were encountered: