-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fixes export destructured variables reference #32007
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
Fixes export destructured variables reference #32007
Conversation
src/services/importTracker.ts
Outdated
@@ -582,6 +582,12 @@ namespace ts.FindAllReferences { | |||
return p.name !== node ? undefined : | |||
p.parent.kind === SyntaxKind.CatchClause ? undefined : p.parent.parent.kind === SyntaxKind.VariableStatement ? p.parent.parent : undefined; | |||
} | |||
else if (parent.parent && parent.parent.parent && parent.parent.parent.kind === SyntaxKind.VariableDeclaration) { |
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.
does this work for binding elements of arbitrary nesting?
export const {foo: [bar, {baz: bas}]} = someObj;
You probably want to use walkUpBindingElementsAndPatterns
to get the VariableDeclaration of the BindingElement.
path: "/mod.ts", | ||
content: `export const value = 0; | ||
export const [valueA, valueB] = [0, 1]; | ||
export const { valueC, valueD } = { valueC: 0, valueD: 1 };`, |
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 you add a test that renames the destructured property export const {foo: bar} = {foo: 2}
to make sure this works as expected
85771cf
to
58ebc92
Compare
@ajafff Thank you for your review, I fixed them |
f2758db
to
7c1dcb7
Compare
f53d3e5
to
7953690
Compare
...override, | ||
}); | ||
|
||
it("should get const variable decralation references", () => { |
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.
it("should get const variable decralation references", () => { | |
it("should get const variable declaration references", () => { |
assert.deepEqual(response, expectResponse); | ||
}); | ||
|
||
it("should get array destructuring decralation references", () => { |
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.
it("should get array destructuring decralation references", () => { | |
it("should get array destructuring declaration references", () => { |
assert.deepEqual(response, expectResponse); | ||
}); | ||
|
||
it("should get object destructuring decralation references", () => { |
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.
it("should get object destructuring decralation references", () => { | |
it("should get object destructuring declaration references", () => { |
assert.deepEqual(response, expectResponse); | ||
}); | ||
|
||
it("should get object decralation references that renames destructured property", () => { |
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.
it("should get object decralation references that renames destructured property", () => { | |
it("should get object declaration references that renames destructured property", () => { |
assert.deepEqual(response, expectResponse); | ||
}); | ||
|
||
it("should get nested object decralation references", () => { |
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.
it("should get nested object decralation references", () => { | |
it("should get nested object declaration references", () => { |
7953690
to
55e8ba9
Compare
@rbuckton Thank you for your review, I fixed each commits to use rebase and edit. |
b2fcb06
to
a1c5600
Compare
b9810ad
to
1829d7b
Compare
878d7f5
to
9cecb5d
Compare
9cecb5d
to
02294a7
Compare
02294a7
to
c04ef90
Compare
Thanks for the contribution! |
Fixes #31922