-
Notifications
You must be signed in to change notification settings - Fork 731
Re-port isUsedInFunctionOrInstanceProperty #1872
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
Conversation
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.
Pull Request Overview
This PR re-ports the isUsedInFunctionOrInstanceProperty function to fix issue #1870. The refactoring replaces a traditional for-loop traversal with the ast.FindAncestorOrQuit utility function for cleaner code structure and improved maintainability.
Key changes:
- Converted loop-based ancestor traversal to use
ast.FindAncestorOrQuitpattern - Updated return statements to use appropriate
ast.FindAncestorResultvalues - Added a test case to verify blocked scope variable behavior
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/checker/checker.go |
Refactored isUsedInFunctionOrInstanceProperty to use ast.FindAncestorOrQuit instead of manual loop traversal |
testdata/tests/cases/compiler/blockedScopeVariableNotUnused1.ts |
Added test case for blocked scope variable usage validation |
testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.* |
Generated baseline files for the new test case |
| initializerOfProperty := propertyDeclaration.Initializer() == current | ||
| if initializerOfProperty { |
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.
Nit on naming and comparison order to make it more readable
| initializerOfProperty := propertyDeclaration.Initializer() == current | |
| if initializerOfProperty { | |
| currentIsInitializer := current == propertyDeclaration.Initializer() | |
| if currentIsInitializer { |
or if you flip the order, I'd argue you don't need a variable anyway
| initializerOfProperty := propertyDeclaration.Initializer() == current | |
| if initializerOfProperty { | |
| if current == propertyDeclaration.Initializer() { |
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.
This is 1:1 ported so I don't really want to futz with it.
Fixes #1870