Skip to content

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

Merged

Conversation

sisisin
Copy link
Contributor

@sisisin sisisin commented Jun 20, 2019

Fixes #31922

@msftclas
Copy link

msftclas commented Jun 20, 2019

CLA assistant check
All CLA requirements met.

@@ -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) {
Copy link
Contributor

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 };`,
Copy link
Contributor

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

@sisisin sisisin force-pushed the fix/destructured-variables-reference branch from 85771cf to 58ebc92 Compare June 22, 2019 08:46
@sisisin
Copy link
Contributor Author

sisisin commented Jun 22, 2019

@ajafff Thank you for your review, I fixed them

@sisisin sisisin force-pushed the fix/destructured-variables-reference branch 3 times, most recently from f2758db to 7c1dcb7 Compare June 26, 2019 14:40
@sisisin sisisin force-pushed the fix/destructured-variables-reference branch 3 times, most recently from f53d3e5 to 7953690 Compare June 28, 2019 13:14
...override,
});

it("should get const variable decralation references", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it("should get nested object decralation references", () => {
it("should get nested object declaration references", () => {

@sisisin sisisin force-pushed the fix/destructured-variables-reference branch from 7953690 to 55e8ba9 Compare June 29, 2019 03:52
@sisisin
Copy link
Contributor Author

sisisin commented Jun 29, 2019

@rbuckton Thank you for your review, I fixed each commits to use rebase and edit.

@sisisin sisisin force-pushed the fix/destructured-variables-reference branch 3 times, most recently from b2fcb06 to a1c5600 Compare July 3, 2019 15:03
@sisisin sisisin force-pushed the fix/destructured-variables-reference branch 2 times, most recently from b9810ad to 1829d7b Compare July 11, 2019 15:57
@sisisin sisisin force-pushed the fix/destructured-variables-reference branch 3 times, most recently from 878d7f5 to 9cecb5d Compare July 23, 2019 12:49
@sisisin sisisin force-pushed the fix/destructured-variables-reference branch from 9cecb5d to 02294a7 Compare July 28, 2019 13:24
@sisisin sisisin force-pushed the fix/destructured-variables-reference branch from 02294a7 to c04ef90 Compare July 31, 2019 13:24
@rbuckton rbuckton merged commit 33a6509 into microsoft:master Aug 5, 2019
@rbuckton
Copy link
Contributor

rbuckton commented Aug 5, 2019

Thanks for the contribution!

@sisisin sisisin deleted the fix/destructured-variables-reference branch August 7, 2019 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsserver does'nt output references that array desturctured variables
4 participants