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

fix(language-service): infer context type of structural directives (#35537) #35561

Closed
wants to merge 1 commit into from

Conversation

kondi
Copy link
Contributor

@kondi kondi commented Feb 19, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • 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?

Issue Number: #35537, #35426

What is the new behavior?

The type of structural directive context is now correctly inferred instead of any. There was a trick before to manually handle the context of ngFor exported values (getNgForExportedValueType function), this is not needed anymore, because my solutions handle them automatically. New unit tests were added to validate this change and also to ensure the fix is actually working.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The implementation works like in angular 8, because it relies on the already existing getTemplateContext method. So the context is inferred from the type parameter of injected TemplateRef. The ivy compiler works differently by relying on ngTemplateContextGuard static method. However, the TemplateRef solution will work with much more existing directives and as I understand, full ivy parity was not scope of language-service v9.

Copy link
Contributor

@kyliau kyliau left a comment

Choose a reason for hiding this comment

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

Thank you very much for the contribution! The change looks good.
We are in the midst of transitioning to integrate the Ivy compiler into language service, and consequently expression_diagnostics_specs.ts will be going away soon.
Do you mind moving the tests to packages/language-service/test/diagnostics_spec.ts?
The custom directive could be moved to packages/language-service/test/project/app/parsing-cases.ts.

Thank you!

@kondi kondi force-pushed the context-type-fix branch 2 times, most recently from ccac7d7 to caf518a Compare February 19, 2020 22:35
@kondi
Copy link
Contributor Author

kondi commented Feb 19, 2020

Do you mind moving the tests to packages/language-service/test/diagnostics_spec.ts?
The custom directive could be moved to packages/language-service/test/project/app/parsing-cases.ts.

Thanks! I have moved the related unit tests. The other cases have been already covered in this file.

Copy link
Contributor

@kyliau kyliau left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@kyliau kyliau added area: language-service Issues related to Angular's VS Code language service action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Feb 20, 2020
@ngbot ngbot bot modified the milestone: needsTriage Feb 20, 2020
@ngbot
Copy link

ngbot bot commented Feb 20, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "pullapprove" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@kyliau kyliau added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Feb 20, 2020
@ayazhafiz
Copy link
Member

mhevery pushed a commit that referenced this pull request Feb 21, 2020
@mhevery mhevery closed this in 54fd33f Feb 21, 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 Mar 23, 2020
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: language-service Issues related to Angular's VS Code language service cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants