fix(compiler-cli): allow declaration-only template type check members (#34296)
The metadata collector for View Engine compilations emits error symbols for static class members that have not been initialized, which prevents a library from building successfully when `strictMetadataEmit` is enabled, which is recommended for libraries to avoid issues in library consumers. This is troublesome for libraries that are adopting static members for the Ivy template type checker: these members don't need a value assignment as only their type is of importance, however this causes metadata errors. As such, a library used to be required to initialize the special static members to workaround this error, undesirably introducing a code-size overhead in terms of emitted JavaScript code. This commit modifies the collector logic to specifically ignore the special static members for Ivy's template type checker, preventing any errors from being recorded during the metadata collection. PR Close #34296
This commit is contained in:
@ -230,7 +230,7 @@ export class MetadataCollector {
|
||||
const property = <ts.PropertyDeclaration>member;
|
||||
if (isStatic(property)) {
|
||||
const name = evaluator.nameOf(property.name);
|
||||
if (!isMetadataError(name)) {
|
||||
if (!isMetadataError(name) && !shouldIgnoreStaticMember(name)) {
|
||||
if (property.initializer) {
|
||||
const value = evaluator.evaluateNode(property.initializer);
|
||||
recordStaticMember(name, value);
|
||||
@ -744,6 +744,10 @@ function namesOf(parameters: ts.NodeArray<ts.ParameterDeclaration>): string[] {
|
||||
return result;
|
||||
}
|
||||
|
||||
function shouldIgnoreStaticMember(memberName: string): boolean {
|
||||
return memberName.startsWith('ngAcceptInputType_') || memberName.startsWith('ngTemplateGuard_');
|
||||
}
|
||||
|
||||
function expandedMessage(error: any): string {
|
||||
switch (error.message) {
|
||||
case 'Reference to non-exported class':
|
||||
|
Reference in New Issue
Block a user