-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JS: QL-side type/name resolution for TypeScript and JSDoc #19078
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
Open
asgerf
wants to merge
42
commits into
github:main
Choose a base branch
from
asgerf:js/name-resolution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,695
−2,180
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cee75ae
to
fa3e5ed
Compare
fe9b23d
to
c07cc6e
Compare
2d928f2
to
3b395af
Compare
3b395af
to
d92247c
Compare
45b09df
to
ae0aeb9
Compare
Overload resolution has little impact on data flow analysis, because there we care about the concrete implementation of the function, which is the same for all overloads. It can affect the return type, which in turn can affect the call graph we generate, but we'll just have to accept this as overload resolution is too hard without negative recursion.
…nt declarations This test enforced the opinion that ambient declarations should have no impact on data flow, which is no longer the case. For now I'm just updating the test output.
aab67e7
to
2b208d6
Compare
2b208d6
to
d644f80
Compare
Napalys
reviewed
Jun 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraordinary... 👏
Co-authored-by: Napalys Klicius <napalys@github.com>
erik-krogh
reviewed
Jun 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still haven't looked closely at the three big commits, but here are some small comments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prepares for disabling TypeScript type extraction by recovering the relevant type information on the QL side.
Actually disabling type extraction will happen in a separate PR so it's easier to validate in isolation and rollback if needed.
The code is divided into three main components:
(Request & { x: T }) | null
hasRequest
as an underlying type.One of the complexities of TypeScript is the fact that there are three "declaration spaces" in which variables can exist: value, type, and namespace. For example, for a declaration like
class C {}
, the valueC
refers to the class itself (i.e. its constructor), whereas the typeC
describes an instance of the class (not the class itself). In practice, it seems that values and namespaces can be merged without problems so I decided to simplify things by doing that.Effects on call graph
main
would lose us 40k call edges on the default benchmark suite..js
files. The new solution has unified support for the two kinds of type annotations, which was not possible previously since we didn't want to run the TypeScript compiler on.js
files.KnownClass | UnresolvedClass
will always propagate information aboutKnownClass
even ifUnresolvedClass
could not be resolved.