Repository navigation
Conversation
…ts in ng-analyze When a standalone component has malformed `foreignImports` entries, `ngtsc` marks the component as poisoned (`isPoisoned = true`) alongside the `NG1010` diagnostics so template type-checking and scope resolution are skipped unless `usePoisonedData` is enabled. That prevents noisy follow-on template errors like `NG8001` for tags that were supposed to be registered by the broken `foreignImports` entry. In `ng-analyze`, non-standalone components with `foreignImports` were already poisoned, and `foreign_import_issues` were extracted and reported as `NG1010`, but `optimize_component` never marked standalone components as poisoned when `foreign_import_issues` was non-empty. As a result, the preprocessor still generated a type-check block for those components and surfaced spurious template errors. This change sets `component.is_poisoned = true` in `optimize_component` after `optimize_component_scope` when a standalone component has any `foreign_import_issues`. Setting it after scope optimization lets `imports` and `deferredImports` validation still report their diagnostics (matching `ngtsc`), while clearing resolved scope fields when `use_poisoned_data` is false and keeping well-formed `foreign_imports` entries intact for template feature analysis and `use_poisoned_data` consumers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a standalone component has malformed
foreignImportsentries,ngtscmarks the component as poisoned (isPoisoned = true) alongside theNG1010diagnostics so template type-checking and scope resolution are skipped unlessusePoisonedDatais enabled. That prevents noisy follow-on template errors likeNG8001for tags that were supposed to be registered by the brokenforeignImportsentry.In
ng-analyze, non-standalone components withforeignImportswere already poisoned, andforeign_import_issueswere extracted and reported asNG1010, butoptimize_componentnever marked standalone components as poisoned whenforeign_import_issueswas non-empty. As a result, the preprocessor still generated a type-check block for those components and surfaced spurious template errors.This change sets
component.is_poisoned = trueinoptimize_componentafteroptimize_component_scopewhen a standalone component has anyforeign_import_issues. Setting it after scope optimization letsimportsanddeferredImportsvalidation still report their diagnostics (matchingngtsc), while clearing resolved scope fields whenuse_poisoned_datais false and keeping well-formedforeign_importsentries intact for template feature analysis anduse_poisoned_dataconsumers.Verification:
bazelisk test //packages/compiler-cli/preprocessor/ng-analyze:test(all 939 tests pass; new tests fail before the fix)bazelisk test //packages/compiler-cli/test/ngtsc:ngtsc //packages/compiler-cli/test/ngtsc:ngtsc_ngp --test_sharding_strategy=disabled --test_arg=--filter="foreign component template semantics"(new test fails onngtsc_ngpwith 4 diagnostics instead of 1 before the fix, passes on both backends after)bazelisk test //packages/compiler-cli/preprocessor/test:test //packages/compiler-cli/preprocessor/test:typecheck_goldens_test(all shards pass with updatedforeign_imports_diagnostics/golden.opt.md)