Diagnostic to flag cases where control flow can break content projection#52726
Diagnostic to flag cases where control flow can break content projection#52726crisbeto wants to merge 4 commits intoangular:mainfrom
Conversation
9665aea to
424bf5d
Compare
There was a problem hiding this comment.
I wasn't totally sure if another TcbOp was the right place to put this since it doesn't add any statements to the TCB, but I saw that we have some precedent for cases in the TcbDomSchemaCheckerOp. My main concern was to isolate the check from everything else in the TCB. The other option was to put it in a private method inside the Scope, but that class is pretty large as it is.
424bf5d to
ff32dce
Compare
cac5480 to
ab83508
Compare
packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
"will not be projected" may be inaccurate if there is a default slot. Perhaps this should have two forms ("will not be projected" and "will be projected into the default projection slot" or smth like that) or generalize to e.g. "will not be projected there".
There was a problem hiding this comment.
I changed the wording a bit to mention that it won't be projected into that slot.
ab83508 to
c8e2b98
Compare
|
I've addressed most of the feedback and will bring up the discussion around using a warning versus an error later today. |
…T nodes When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in `compiler-cli`.
…spaces during template type checking These changes expose the `ngContentSelectors` and `preserveWhitespaces` metadata to the TCB so they can be used in the next commit to implement a new diagnostic.
…tainer The control flow projection diagnostic will mention `ng-container` as a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works.
5a0f84f to
f49fa26
Compare
f49fa26 to
f6548e9
Compare
…ent projection This is a follow-up to the fix from angular#52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…T nodes (angular#52726) When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in `compiler-cli`. PR Close angular#52726
…spaces during template type checking (angular#52726) These changes expose the `ngContentSelectors` and `preserveWhitespaces` metadata to the TCB so they can be used in the next commit to implement a new diagnostic. PR Close angular#52726
…tainer (angular#52726) The control flow projection diagnostic will mention `ng-container` as a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works. PR Close angular#52726
…ent projection (angular#52726) This is a follow-up to the fix from angular#52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot. PR Close angular#52726
…T nodes (angular#52726) When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in `compiler-cli`. PR Close angular#52726
…spaces during template type checking (angular#52726) These changes expose the `ngContentSelectors` and `preserveWhitespaces` metadata to the TCB so they can be used in the next commit to implement a new diagnostic. PR Close angular#52726
…tainer (angular#52726) The control flow projection diagnostic will mention `ng-container` as a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works. PR Close angular#52726
…ent projection (angular#52726) This is a follow-up to the fix from angular#52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot. PR Close angular#52726
…T nodes (angular#52726) When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in `compiler-cli`. PR Close angular#52726
…spaces during template type checking (angular#52726) These changes expose the `ngContentSelectors` and `preserveWhitespaces` metadata to the TCB so they can be used in the next commit to implement a new diagnostic. PR Close angular#52726
…tainer (angular#52726) The control flow projection diagnostic will mention `ng-container` as a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works. PR Close angular#52726
…ent projection (angular#52726) This is a follow-up to the fix from angular#52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot. PR Close angular#52726
These changes are a follow-up to the fix from #52414. They add a new diagnostic to the compiler that will flag cases where an element would've been projected into a specific slot of a component, but it isn't because it exists inside of a control flow node that has multiple root nodes. Aside from the diagnostic, I have to move some code around so it can be reused. Includes the following commits:
refactor(compiler): expose utility for creating CSS selectors from AST nodes
When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in
compiler-cli.refactor(compiler-cli): expose ng-content selectors and preserveWhitespaces during template type checking
These changes expose the
ngContentSelectorsandpreserveWhitespacesmetadata to the TCB so they can be used in the next commit to implement a new diagnostic.test(core): add tests for control flow content projection with ng-container
The control flow projection diagnostic will mention
ng-containeras a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works.fix(compiler-cli): add diagnostic for control flow that prevents content projection
This is a follow-up to the fix from #52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot.