Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JS: Disable type extraction #19640

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
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Jun 2, 2025

Disabling type extraction

We used to rely on the TypeScript compiler's type checker for getting type information during extraction. As of this PR, we only use the TypeScript compiler for parsing, and instead use CodeQL logic to obtain the needed type information ourselves.

Why?

Faster extraction: We're seeing 20-80% faster extraction times for TypeScript code bases. The wins here tend to outweigh the added cost on the QL side.

Incremental extraction: Type extraction was incompatible with "overlay mode". With this change, TypeScript files can be extracted in isolation from each other, meaning we only have to parse the files that have changed when building an overlay database.

Robustness: TypeScript extraction rarely fails, but when it does, it is usually because of type extraction. At least three public issues (1, 2, 3) and several internal ones are ultimately about type extraction problems. Several issues with type extraction have surfaced and been fixed over the years, but there's been a tendency for the "fixes" to be workarounds for problems that we don't have enough control over from the extractor.

Deprecations and breaking changes

This PR deprecates Type and other APIs relating to extracted types, and introduces a simple interface for interacting with the new QL-based name/type resolution.

Queries relying on Type and friends should still compile (with deprecation warnings) but won't have the same results since Type is now empty. The change notes therefore lists this as a breaking change. We try to avoid breaking changes when at all possible, but there is no viable mechanism for avoiding it in this case.

Call graph changes

When I made the original call graph estimates in the previous PR, I had unfortunately not disabled the influence of type extraction completely, meaning we lose more call edges than originally estimated.

This PR adds a few more fixes to recover some of them, but as seen in the evaluation we still lose 25k call edges. However, this only results in 1 lost alert, which was a FP. I have some follow-up work with generics that recovers about a third of the call edges. Despite the lost call edges, I'd like to move ahead with this PR as the pros clearly outweigh the cons at this point, and it means we can unblock other works that depend on it.

@github-actions github-actions bot added the JS label Jun 2, 2025
name = spec.getExportedName() and
result = spec.getLocal()
)
or

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.
name = sig.getName()
)
private class MethodCallSig extends Function {
private MethodSignature signature;

Check notice

Code scanning / CodeQL

Field only used in CharPred Note

Field is only used in CharPred.
@asgerf asgerf force-pushed the js/no-type-extraction branch from 7ba856a to 2cd92ef Compare June 4, 2025 10:51
Comment on lines +10 to +12
/**
* Interface for accessing name-resolution info about type names.
*/

Check warning

Code scanning / CodeQL

Class QLDoc style. Warning

The QLDoc for a class should start with 'A', 'An', or 'The'.
Comment on lines +142 to +144
/**
* Interface for accessing name-resolution info about expressions.
*/

Check warning

Code scanning / CodeQL

Class QLDoc style. Warning

The QLDoc for a class should start with 'A', 'An', or 'The'.
@asgerf asgerf force-pushed the js/no-type-extraction branch 5 times, most recently from 9521fbb to 2035925 Compare June 11, 2025 08:48
@asgerf asgerf force-pushed the js/no-type-extraction branch from 4ba014d to a039c1b Compare June 23, 2025 10:57
@asgerf asgerf force-pushed the js/no-type-extraction branch 2 times, most recently from 3a1fae6 to 1729f7a Compare June 24, 2025 15:50
asgerf added 9 commits June 25, 2025 14:31
This check existed on the code path for full type extraction, but not for plain single-file extraction.
The 'extractTypeScriptFiles' override did not incorporate the file type and one of our unit tests was expecting this. The test was previously passing for the wrong reasons.
@asgerf asgerf force-pushed the js/no-type-extraction branch from 1729f7a to 5289e4f Compare June 25, 2025 12:37
@asgerf asgerf changed the title JS: Deprecate type extraction JS: Disable type extraction Jun 25, 2025
@asgerf asgerf marked this pull request as ready for review June 25, 2025 13:16
@asgerf asgerf requested a review from a team as a code owner June 25, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant