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

fix(noUndeclaredVariables): bind read in ambient context to import type #4547

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

Conaclos
Copy link
Member

@Conaclos Conaclos commented Nov 15, 2024

Summary

Fix #4526 and fix #4547

The semantic model now tracks if the traversed node is in an ambient context not.
The scope registers if it is in ambient context to properly restore the information once we leave a scope.

When we are in an ambient context we emit AmbientRead instead of Read.
This allows us to bind ambient read to type-only imports.

Test Plan

I added some tests.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Nov 15, 2024
@Conaclos Conaclos requested review from a team November 15, 2024 13:11
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48594 48594 0
Passed 47402 47402 0
Failed 1192 1192 0
Panics 0 0 0
Coverage 97.55% 97.55% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6586 6586 0
Passed 2208 2208 0
Failed 4378 4378 0
Panics 0 0 0
Coverage 33.53% 33.53% 0.00%

ts/babel

Test result main count This PR count Difference
Total 680 680 0
Passed 608 608 0
Failed 72 72 0
Panics 0 0 0
Coverage 89.41% 89.41% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18608 18608 0
Passed 14263 14263 0
Failed 4345 4345 0
Panics 0 0 0
Coverage 76.65% 76.65% 0.00%

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Just a nit

Comment on lines 289 to 293
is_closure: bool,
implies_strict_mode: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Can we document all the new types an fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not new, I just encapsulated them in a type to make it simpler to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added some doctests.

@Conaclos Conaclos force-pushed the conaclos/js-semantic-ambient-context branch 2 times, most recently from 21954bc to 4b1e836 Compare November 15, 2024 20:30
@Conaclos Conaclos merged commit ed29d73 into main Nov 15, 2024
11 checks passed
@Conaclos Conaclos deleted the conaclos/js-semantic-ambient-context branch November 15, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 false positive with noUndeclaredVariables in *.d.ts files
2 participants