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

feat(core): add light version of the semantic model to scanner #5599

Merged
merged 3 commits into from
Apr 7, 2025

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Apr 7, 2025

Summary

Fixes #5312.

This adds a light, and as of yet incomplete, version of the semantic model to the scanner. The goal isn't yet to do deep semantic analysis inside the scanned modules, but simply to resolve exported symbols when their declaration is in a different position than the export statement itself.

This makes sure that we can resolve both types and JSDoc comments more accurately through the module graph, and also resolves one of the limitations of noPrivateImports that we had in the beta.

JSDoc comments also have a dedicated type. The type definitions for type aliases has been refined as well.

Test Plan

Tests added and snapshots updated.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@arendjr arendjr requested review from a team April 7, 2025 13:15
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Apr 7, 2025
Copy link

codspeed-hq bot commented Apr 7, 2025

CodSpeed Performance Report

Merging #5599 will not alter performance

Comparing arendjr:js-semantic-model-light (968b6cf) with main (b0a035b)

Summary

✅ 95 untouched benchmarks

Comment on lines +83 to +85
/// A `let` or `const` declaration.
///
/// The type (either declared or inferred) of the value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We should add var and using too :) or make the docs a bit more generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var is covered under HoistedValue instead. using isn't covered yet, but also makes no sense in the context of exports, I think.


impl JsDeclarationKind {
/// Returns `true` for any declaration that _may_ be a type.
fn might_be_type(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to understand the semantic difference between "might be a type" (might_be_type) and "is a type" (is_a_type), because a "might" could be translated into a enum where "maybe" is a valid variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mainly due to the presence of the Import variant, where we don't know whether it's a type or a value being imported.

I'll clarify it with a comment.

@arendjr arendjr force-pushed the js-semantic-model-light branch from 9029e92 to 968b6cf Compare April 7, 2025 17:42
@arendjr arendjr merged commit 3a1e773 into biomejs:main Apr 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

📎 Extract semantic exports during scanning
2 participants