Repository navigation
Conversation
…nly in ngtsc `ComponentDecoratorHandler.analyze` previously skipped `extractForeignImportsFromAst` when `emitDeclarationOnly` was enabled, leaving `foreignImports` as `null`. Because `analyze` still runs `analyzeForeignComponentFeatures` on the parsed template and `compileLocal` still ingests the template AST under `emitDeclarationOnly`, leaving `foreignImports` unset caused two problems: Valid components using `foreignImports` together with `@content` blocks failed declaration-only emission with a false-positive `NG8026` diagnostic claiming `@content` blocks are only valid as direct children of foreign components (and would fail template ingestion on `ContentBlock` if not stopped there). Malformed `foreignImports` entries were also silently skipped under `emitDeclarationOnly` in `ngtsc` while NGP still reported `NG1010`. Since `extractForeignImportsFromAst` inspects only the local decorator AST with no cross-file resolution or type-checker dependency, running it unconditionally is safe for isolated declarations, fixes `@content` under `emitDeclarationOnly`, and brings `ngtsc` and NGP into parity.
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.
ComponentDecoratorHandler.analyzepreviously skippedextractForeignImportsFromAstwhenemitDeclarationOnlywas enabled, leavingforeignImportsasnull. Becauseanalyzestill runsanalyzeForeignComponentFeatureson the parsed template andcompileLocalstill ingests the template AST underemitDeclarationOnly, leavingforeignImportsunset caused two problems:Valid components using
foreignImportstogether with@contentblocks failed declaration-only emission with a false-positiveNG8026diagnostic claiming@contentblocks are only valid as direct children of foreign components (and would fail template ingestion onContentBlockif not stopped there). MalformedforeignImportsentries were also silently skipped underemitDeclarationOnlyinngtscwhile NGP still reportedNG1010.Since
extractForeignImportsFromAstinspects only the local decorator AST with no cross-file resolution or type-checker dependency, running it unconditionally is safe for isolated declarations, fixes@contentunderemitDeclarationOnly, and bringsngtscand NGP into parity.Verification:
bazelisk test //packages/compiler-cli/test/ngtsc:ngtsc //packages/compiler-cli/test/ngtsc:ngtsc_ngp --test_sharding_strategy=disabled --test_arg=--filter="declaration-only emission"(both new tests fail onngtscbefore the fix and pass on both backends after)bazelisk test //packages/compiler-cli/src/ngtsc/annotations/component/test:all //packages/compiler-cli/test/compliance/declaration-only:all(all targets pass)