Skip to content

Allow to find all references of the 'this 'keyword #9270

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
4 commits merged into from
Jun 24, 2016
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jun 20, 2016

Fixes #9198. Closes #9037 because we don't need to prevent renaming if it works.

@@ -3198,6 +3198,13 @@ namespace ts {
return undefined;
}

//neater
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

Whoops, pushed WIP

@ghost ghost force-pushed the this_references branch 3 times, most recently from aca2d6c to f1f82e1 Compare June 20, 2016 20:55
@ghost ghost closed this Jun 20, 2016
@ghost ghost reopened this Jun 20, 2016
@ghost ghost force-pushed the this_references branch from f1f82e1 to 07437a6 Compare June 21, 2016 12:56
@@ -2388,6 +2388,8 @@ namespace ts {
parameters: Symbol[]; // Parameters
thisType?: Type; // type of this-type
/* @internal */
thisParameter?: Symbol; // symbol of this-type parameter
Copy link
Member

@sandersn sandersn Jun 21, 2016

Choose a reason for hiding this comment

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

It was never quite right to resolve thisType in getSignatureOfDeclaration so switching to a symbol is an improvement. But it means that you should remove thisType entirely and replace usages with getTypeOfSymbol(sig.thisParameter).

@sandersn
Copy link
Member

Looks good except for getting rid of thisType in favor of thisParameter.

@sandersn
Copy link
Member

@yuit and I discussed the removal of thisType a little. getTypeOfVariableOfParameterOrProperty (called by getTypeOfSymbol) may need a new case, something like

if (declaration.kind === SyntaxKind.Identifier && declaration.originalKeyword.kind === SytaxKind.ThisKeyword) {
  return links.type = declaration.type ? getTypeFromTypeNode(declaration.type) : unknownType;
}

Of course you may need to add some type assertions in there.

return parameter && parameter.symbol;
}

function getAnnotatedAccessorThisType(accessor: AccessorDeclaration): Type | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

is this used now?

Copy link
Author

Choose a reason for hiding this comment

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

Linter would complain if it weren't.

Copy link
Member

Choose a reason for hiding this comment

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

I looked it up: checkAccessorDeclaration still uses it.

@sandersn
Copy link
Member

👍

@ghost ghost merged commit 999ac0a into master Jun 24, 2016
@ghost ghost deleted the this_references branch June 24, 2016 13:24
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants