-
Notifications
You must be signed in to change notification settings - Fork 659
fix(rome_js_analyze): noRedeclare accepts index signatures #4519
Conversation
✅ Deploy Preview for docs-rometools ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
Anything we can do to help get this out of draft? |
I need to accept the case below while fixing the problem. current implementation is not enough. type IndexSignatures = {
[index: number]: string,
[index: string]: string
} |
chore: CHANGELOG.md chore: fix indefinite articles wip wip chore: fix comment test: update snapshot chore: update the CHANGELOG.md
fn are_same_type_members( | ||
first: &TsIndexSignatureTypeMember, | ||
second: &TsIndexSignatureTypeMember, | ||
) -> Option<bool> { | ||
let first_text_range = first | ||
.parent::<TsTypeMemberList>()? | ||
.syntax() | ||
.text_trimmed_range(); | ||
|
||
let second_text_range = second | ||
.parent::<TsTypeMemberList>()? | ||
.syntax() | ||
.text_trimmed_range(); | ||
Some(first_text_range == second_text_range) | ||
} |
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 want to check if we have the same parent TsTypeMember.
Other than using text_range, is there any other way to check that they are defined with the same parent (same location)?
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.
Can we compare their parent nodes?
let first_parent = first
.parent::<TsTypeMemberList>()?;
let second_parent = second
.parent::<TsTypeMemberList>()?;
Some(first_parent == second_parent)
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.
Indeed. We should be able to plainly compare two nodes using ==
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.
Thanks, I refactored.
…b.com/unvalley/tools into fix-no-redeclare-for-index-signatures
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.
Looks good to me!
Summary
Closes #4478 #4545
Test Plan
cargo test -p rome_js_analyze -- no_redeclare
Handle these test cases:
Changelog
Documentation