Skip to content
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

Ivy LS: TemplateTypeChecker operation to get ts.Symbol for input #38063

Closed
alxhub opened this issue Jul 15, 2020 · 1 comment
Closed

Ivy LS: TemplateTypeChecker operation to get ts.Symbol for input #38063

alxhub opened this issue Jul 15, 2020 · 1 comment
Assignees
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: language-service Issues related to Angular's VS Code language service feature Issue that requests a new feature
Milestone

Comments

@alxhub
Copy link
Member

alxhub commented Jul 15, 2020

Add a TemplateTypeChecker operation to retrieve a ts.Symbol given a pointer to an input binding within the template AST. This can potentially be resolved without referring to the TCB.

@alxhub alxhub added feature Issue that requests a new feature area: language-service Issues related to Angular's VS Code language service area: compiler Issues related to `ngc`, Angular's template compiler labels Jul 15, 2020
@ngbot ngbot bot added this to the Backlog milestone Jul 15, 2020
@alxhub alxhub added this to Backlog in Ivy Language Service via automation Jul 15, 2020
@alxhub alxhub self-assigned this Jul 21, 2020
@alxhub alxhub moved this from Backlog to Issues In Progress in Ivy Language Service Jul 21, 2020
atscott added a commit to atscott/angular that referenced this issue Aug 11, 2020
…eTypeChecker

Adds the ability to get the `ts.Symbol`s for the Directive and/or Component
that an input in a template binds to.

Fixes angular#38063
atscott added a commit to atscott/angular that referenced this issue Aug 11, 2020
…eTypeChecker

Adds the ability to get the `ts.Symbol`s for the Directive and/or Component
that an input in a template binds to.

Fixes angular#38063
@atscott atscott moved this from Issues In Progress to PRs In Review in Ivy Language Service Aug 11, 2020
atscott added a commit to atscott/angular that referenced this issue Aug 13, 2020
…eTypeChecker

Adds the ability to get the `ts.Symbol`s for the Directive and/or Component
that an input in a template binds to.

Fixes angular#38063
atscott added a commit to atscott/angular that referenced this issue Aug 27, 2020
…eTypeChecker

Adds the ability to get the `ts.Symbol`s for the Directive and/or Component
that an input in a template binds to.

Fixes angular#38063

feat(compiler-cli): Add ability to retrieve symbol from ast

Add `TemplateTypeChecker` operation to retrieve the `ts.Symbol` of an AST expression
from a template. Not all expressions will have symbols (e.g. there is no symbol
associated with the expression a + b, but there are symbols for both the a and b
nodes individually).

Sometimes we need to traverse an intermediate variable declaration to arrive at
the correct `ts.Symbol`. For example, loop variables are declared using an intermediate:
```
<div *ngFor="let user of users">
  {{user.name}}
</div>
```
Getting the symbol of user here (from the expression) is tricky, because the TCB looks like:

```
var _t0 = ...; // type of NgForOf
var _t1: any; // context of embedded view for NgForOf structural directive
if (NgForOf.ngTemplateContextGuard(_t0, _t1)) {
  // _t1 is now NgForOfContext<...>
  var _t2 = _t1.$implicit; // let user = '$implicit'
  _t2.name; // user.name expression
}
```
Just getting the `ts.Expression` for the `AST` node `PropRead(ImplicitReceiver, 'user')`
via the sourcemaps will yield the `_t2` expression.  This function recognizes that `_t2`
is an aliasing variable declared locally in the TCB, and actually fetch the `ts.Symbol` of its initializer.

There is also similar special case handling for `#ref` local references
as well.

Resolves angular#38064

feat(compiler-cli): Add ability to retrieve type from ast

This adds the ability to retrieve type from template ast
@atscott atscott moved this from PRs In Review to Done in Ivy Language Service Sep 21, 2020
@atscott atscott closed this as completed Oct 12, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: language-service Issues related to Angular's VS Code language service feature Issue that requests a new feature
Projects
No open projects
2 participants