Skip to content

Extended template checks - #42984

Closed
danieltre23 wants to merge 8 commits into
angular:masterfrom
danieltre23:template-checks
Closed

danieltre23 wants to merge 8 commits into
angular:masterfrom
danieltre23:template-checks

Conversation

@danieltre23

@danieltre23 danieltre23 commented Jul 28, 2021 •

Copy link
Copy Markdown
Contributor

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?

The compiler currently doesn't really generates warning.

Issue Number: #42966

What is the new behavior?

This PR introduces the extended package which should be able to generate diagnostics after type checking (integration with the compiler should come in a future PR). The API provides an interface for TemplateChecks to be authored, the package also has a function to generate the extended template diagnostics. The banana in a box check, that validates the two-way binding syntax is implemented with it's unit test.

The extended package is private, the only modification to the public API is the new BANANA_IN_BOX ErrorCode.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@danieltre23 danieltre23 added the target: patch This PR is targeted for the next patch release label Jul 28, 2021
@google-cla google-cla Bot added the cla: yes label Jul 28, 2021
@danieltre23
danieltre23 force-pushed the template-checks branch 2 times, most recently from 1db63b9 to 915515b Compare July 28, 2021 19:38
@dylhunn dylhunn added the area: compiler Issues related to `ngc`, Angular's template compiler label Jul 28, 2021
@ngbot ngbot Bot added this to the Backlog milestone Jul 28, 2021

@dgp1130 dgp1130 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.

Great work on an initial proposal here, looking really good!

Mostly just a bunch of nitpicks, a few stylistic comments, and a couple questions about edge cases. Nothing too concerning with this PR, hope we can land it soon!

@danieltre23
danieltre23 force-pushed the template-checks branch 2 times, most recently from 737eb07 to 9da58bc Compare August 2, 2021 18:46
alxhub
alxhub previously requested changes Aug 3, 2021
@danieltre23
danieltre23 force-pushed the template-checks branch 2 times, most recently from df24977 to e12f69e Compare August 4, 2021 17:05
Comment thread packages/compiler/src/render3/r3_ast.ts Outdated

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.

Thanks for making this fix and for keeping it in a separate commit, much easier to understand the context this way!

@danieltre23
danieltre23 removed the request for review from IgorMinar August 10, 2021 21:01
@danieltre23 danieltre23 added the action: merge The PR is ready for merge by the caretaker label Aug 10, 2021
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…42984)

specific

This commit makes the wrapper function `makeTemplateDiagnostic` take an
ErrorCode as a type for the `ts.Diagnostic`s to be generated.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…omponent` function (#42984)

Add function to get extended template diagnostics generated by all the template checks.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
#42984)

This commit moves the test utils used in the typechecking tests into its
own package. This makes them available to be used in the tests of a
different package.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…42984)

Export `getSourceCodeForDiagnostic` from `ngtsc/testing` to make it
available for other packages. This will help confirm that the source
code is correct in other tests.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…plates (#42984)

This commit adds to the exisiting `RecursiveVisitor` and visits inputs
and outputs for elements and templates.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…#42984)

Add the implementation of a Template Check that ensures the correct
use of two-way binding syntax. Generates a warning when
'([foo])="bar"' is found instead of '[(foo)]="bar"'.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
Create the test package for extended_template_diagnostics and add a unit
test for the `BananaInBoxCheck`.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…it's API (#42984)

This commit introduces //packages/compiler-cli/src/ngtsc/typecheck/extended
as a container for a new phase of diagnostics generation. The API provides an
interface for new template checks to implement and generate template diagnostics.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…42984)

specific

This commit makes the wrapper function `makeTemplateDiagnostic` take an
ErrorCode as a type for the `ts.Diagnostic`s to be generated.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…omponent` function (#42984)

Add function to get extended template diagnostics generated by all the template checks.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
#42984)

This commit moves the test utils used in the typechecking tests into its
own package. This makes them available to be used in the tests of a
different package.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…42984)

Export `getSourceCodeForDiagnostic` from `ngtsc/testing` to make it
available for other packages. This will help confirm that the source
code is correct in other tests.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…plates (#42984)

This commit adds to the exisiting `RecursiveVisitor` and visits inputs
and outputs for elements and templates.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
…#42984)

Add the implementation of a Template Check that ensures the correct
use of two-way binding syntax. Generates a warning when
'([foo])="bar"' is found instead of '[(foo)]="bar"'.

Refs #42966

PR Close #42984
AndrewKushnir pushed a commit that referenced this pull request Aug 10, 2021
Create the test package for extended_template_diagnostics and add a unit
test for the `BananaInBoxCheck`.

Refs #42966

PR Close #42984
@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.

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 cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants