X Tutup
The Wayback Machine - https://web.archive.org/web/20220305043048/https://github.com/angular/angular/pull/42984
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

Extended template checks #42984

Closed
wants to merge 8 commits into from
Closed

Conversation

danieltre23
Copy link
Contributor

@danieltre23 danieltre23 commented Jul 28, 2021

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 requested review from atscott, alxhub and dgp1130 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 Jul 28, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 28, 2021
Copy link
Contributor

@dgp1130 dgp1130 left a comment

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 Aug 2, 2021
@danieltre23 danieltre23 force-pushed the template-checks branch 2 times, most recently from df24977 to e12f69e Aug 4, 2021
@danieltre23 danieltre23 requested review from atscott, dgp1130 and alxhub Aug 4, 2021
atscott
atscott approved these changes Aug 4, 2021
packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/ngtsc/testing/src/utils.ts Outdated Show resolved Hide resolved
@@ -203,11 +203,15 @@ export class NullVisitor implements Visitor<void> {
export class RecursiveVisitor implements Visitor<void> {
visitElement(element: Element): void {
visitAll(this, element.attributes);
visitAll(this, element.inputs);
visitAll(this, element.outputs);
Copy link
Contributor

@dgp1130 dgp1130 Aug 4, 2021

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!

AndrewKushnir added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue Aug 10, 2021
Create the test package for extended_template_diagnostics and add a unit
test for the `BananaInBoxCheck`.

Refs #42966

PR Close #42984
@danieltre23 danieltre23 mentioned this pull request Aug 19, 2021
14 tasks
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…it's API (angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…ngular#42984)

specific

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…omponent` function (angular#42984)

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…ngular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…plates (angular#42984)

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
Create the test package for extended_template_diagnostics and add a unit
test for the `BananaInBoxCheck`.

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…it's API (angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…ngular#42984)

specific

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…omponent` function (angular#42984)

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…ngular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…plates (angular#42984)

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

Refs angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…angular#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 angular#42966

PR Close angular#42984
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
Create the test package for extended_template_diagnostics and add a unit
test for the `BananaInBoxCheck`.

Refs angular#42966

PR Close angular#42984
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 26, 2021

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 Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
X Tutup