Skip to content

feat(compiler-cli): resolve type of exported *ngIf variable. - #33016

Closed
andrius-pra wants to merge 1 commit into
angular:masterfrom
andrius-pra:resolve-type-of-exported-var
Closed

andrius-pra wants to merge 1 commit into
angular:masterfrom
andrius-pra:resolve-type-of-exported-var

Conversation

@andrius-pra

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Angular compiler does not resolve the type of exported variable from *ngIf directive. It always returns any type. So language service can't provide completions for type members.

Issue Number: angular/vscode-ng-language-service#255

What is the new behavior?

Compiler will try resolve type of exported variable and will use this type for type-checking. Angular language service will use this type for completions, go to definition and quick info functionality. Also language service will provide more accurate diagnostic errors during development.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@andrius-pra
andrius-pra requested a review from a team October 5, 2019 13:33

@ayazhafiz ayazhafiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add tests that check that this change correctly determines the type of exported variable?

@andrius-pra
andrius-pra requested a review from a team October 8, 2019 19:55

@ayazhafiz ayazhafiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry that I wasn't more clear earlier @andrius-pra; what I mean is, can we also add tests that bindingType returned in the compiler code is what we expect it to be?

@andrius-pra

Copy link
Copy Markdown
Contributor Author

@ayazhafiz, I'm not sure where I should add this test. Tests of compiler-cli doesn't check the type of scoped variables. It only verify that compiler will produce specific diagnostic message. Do I need to introduce a new type of tests in compiler-cli package that will check result of getExpressionScope or getVarDeclarations?

@ayazhafiz

Copy link
Copy Markdown
Contributor

I'm not sure. Perhaps it is best to defer to the compiler team to ask what they would like to do. ping @angular/fw-compiler

@ayazhafiz ayazhafiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM for Language Service

@kyliau kyliau added area: compiler Issues related to `ngc`, Angular's template compiler area: language-service Issues related to Angular's VS Code language service target: major This PR is targeted for the next major release labels Oct 10, 2019
@ngbot ngbot Bot modified the milestone: needsTriage Oct 10, 2019

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be really helpful for reference to include more information in the commit message, explaining what this commit is doing an why it is needed.
Perhaps similar to what has been written in the description PR?

Currently, method `getVarDeclarations()` does not try to resolve the type of
exported variable from *ngIf directive. It always returns `any` type.
By resolving the real type of exported variable, it is now possible to use this
type information in language service and provide completions, go to definition
and quick info functionality in expressions that use exported variable.
Also language service will provide more accurate diagnostic errors during
development.
@andrius-pra

Copy link
Copy Markdown
Contributor Author

I have updated commit message.

@IgorMinar IgorMinar added the action: merge The PR is ready for merge by the caretaker label Oct 14, 2019
@IgorMinar

Copy link
Copy Markdown
Contributor

thank you @andrius-pra!

@angular-automatic-lock-bot

Copy link
Copy Markdown

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 14, 2019
@andrius-pra
andrius-pra deleted the resolve-type-of-exported-var branch January 17, 2020 21:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: language-service Issues related to Angular's VS Code language service cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants