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

Automatic skipDefaultLibCheck (and potentially skipLibCheck) #31417

Open
DanielRosenwasser opened this issue May 15, 2019 · 2 comments
Open

Automatic skipDefaultLibCheck (and potentially skipLibCheck) #31417

DanielRosenwasser opened this issue May 15, 2019 · 2 comments
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Domain: Performance Reports of unusually slow behavior In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented May 15, 2019

This issue is adapted from a work item discussed at #25658.

Automatic skipDefaultLibCheck

lib.d.ts is a pretty big file, and it's only going to grow. Realistically, most people don't ever declare symbols that conflict with the global scope, so we made the skipDefaultLibCheck (and also the skipLibCheck flag) for faster compilations.

We can suggest this flag to users, but the truth is that it's not discoverable. It's also often misused, so I want to stop recommending it to people. 😄

It'd be interesting to see if we can get the same results of skipDefaultLibCheck based on the code users have written. Any program that doesn't contribute a global augmentation, or a declaration in the global scope, doesn't really need to have lib.d.ts checked over again.

@mhegazy and I have discussed this, and it sounds like we have the necessary information after the type-checker undergoes symbol-merging. If no symbols ever get merged outside of lib files, we can make the assumption that lib files never need to get checked. But this requires knowing that all lib files have already had symbols merged up front before any other files the compiler is given.

Open Questions

  • Is the idea to only type-check symbols which have been merged? Or is it to fall back to the worst-case behavior of checking everything when any symbol has been merged across files?
    • If it's the only checking merged entities, does declare class B extend A {} need to be re-checked if A has ever been subsequently merged? How would we keep track of that information?
    • If it's falling back to the worst-case behavior, does this feature actually help anyone outside of the "Hello world" case?

Cons

  • It feels like there are certain interactions we may be overlooking - we will have to be careful about our assumptions in the compiler with this behavior in place.
  • Users who edit lib.d.ts wouldn't see erroneous changes in a compiler (so we'd likely need a forceDefaultLibCheck).

Pros

  • Running with skipDefaultLibCheck removes anywhere between 400-700ms on my machine from a "Hello world" file, so we could expect the same here under this behavior.
  • Only our team ever needs to run forceDefaultLibCheck, reducing the cost for all other TypeScript users.
@DanielRosenwasser DanielRosenwasser added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels May 15, 2019
@DanielRosenwasser DanielRosenwasser changed the title Automatic skipDefaultLibCheck Automatic skipDefaultLibCheck (and potentially skipLibCheck) May 15, 2019
@DanielRosenwasser DanielRosenwasser added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Domain: Performance Reports of unusually slow behavior labels May 15, 2019
@nmain
Copy link

nmain commented May 16, 2019

Realistically, most people don't ever declare symbols that conflict with the global scope

Is there any way to test this assumption? Perhaps compiling the DT types both with and without skipDefaultLibCheck and looking for any differences in results?

@ajafff
Copy link
Contributor

ajafff commented May 16, 2019

Can users of @types/node benefit from this? Last time I checked they used forward declarations that merged with symbols in lib.d.ts. If that's still the case, it would prevent this optimization, wouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Domain: Performance Reports of unusually slow behavior In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants