With compilationMode: 'partial', components lose all their queries. Directives are fine. After linking, @ViewChild / @ContentChild on a library component is never set.
Repro (compilationMode: 'partial')
import {Component, Directive, ViewChild, ContentChild, ElementRef} from '@angular/core';
@Component({selector: 'c', template: '<div #a></div>'})
export class C { @ViewChild('a') q!: ElementRef; @ContentChild('b') c: any; }
@Directive({selector: '[d]'})
export class D { @ViewChild('a') q!: ElementRef; @ContentChild('b') c: any; }
OXC (main and #504 tip)
static ɵcmp = i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"0.0.0-PLACEHOLDER",type:C,selector:"c",
ngImport:i0,template:"<div #a></div>",isInline:true});
static ɵdir = i0.ɵɵngDeclareDirective({minVersion:"14.0.0",version:"0.0.0-PLACEHOLDER",type:D,selector:"[d]",
queries:[{propertyName:"c",first:true,predicate:["b"],descendants:true}],viewQueries:[{propertyName:"q",first:true,predicate:["a"],descendants:true}],ngImport:i0});
ngtsc 22.1.7
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: C, isStandalone: true, selector: "c", queries: [{ propertyName: "c", first: true, predicate: ["b"], descendants: true }], viewQueries: [{ propertyName: "q", first: true, predicate: ["a"], descendants: true }], ngImport: i0, template: '<div #a></div>', isInline: true });
Where
crates/oxc_angular_compiler/src/partial/component.rs (compile_declare_component_from_metadata) builds from ComponentMetadata, which has no query fields. partial/directive.rs has queries / viewQueries (and the 17.2.0 signal-query version bump). The comment in partial/component.rs ("Signal queries — ... the metadata struct doesn't include them") notes this gap.
On main?
Yes.
Direction
Pass the component's content and view queries (decorator, queries: and signal queries) to the partial component emitter. Reuse the directive's compile_queries_array and its minVersion bump.
With
compilationMode: 'partial', components lose all their queries. Directives are fine. After linking,@ViewChild/@ContentChildon a library component is never set.Repro (
compilationMode: 'partial')OXC (main and #504 tip)
ngtsc 22.1.7
Where
crates/oxc_angular_compiler/src/partial/component.rs(compile_declare_component_from_metadata) builds fromComponentMetadata, which has no query fields.partial/directive.rshasqueries/viewQueries(and the 17.2.0 signal-query version bump). The comment inpartial/component.rs("Signal queries — ... the metadata struct doesn't include them") notes this gap.On main?
Yes.
Direction
Pass the component's content and view queries (decorator,
queries:and signal queries) to the partial component emitter. Reuse the directive'scompile_queries_arrayand its minVersion bump.