-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Closed
Closed
Copy link
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerfreq2: mediumhotlist: components teamRelated to Angular CDK or Angular MaterialRelated to Angular CDK or Angular Materialtype: bug/fix
Milestone
Description
🐞 bug report
Affected Package
@angular/compiler-cli
Is this a regression?
No
Description
Switching between ngtsc and ngc is not possible when coercion static members are declared for components. e.g.
class MyComp {
...
static ngAcceptInputType_disabled: boolean | string;
}
This works as expected in ngtsc, but as soon as the project is compiled with ngc
, the metadata validator throws an exception:
Error encountered in metadata generated for exported symbol 'MyComp':
/home/circleci/ng/src/cdk/my-comp.ts:422:10:
Metadata collected contains an error that will be reported at runtime: Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler.
{"__symbolic":"error","message":"Variable not initialized","line":421,"character":9}
The error for the static members is actually valid since it only happens if strictMetadataEmit
is enabled.. and this means that NGC validates that there is no unresolved symbol in the source file metadata. Though, since libraries want to keep that flag enabled to ensure that the metadata works in all cases, we need a way to skip accept coercion members for Ivy/ViewEngine compatibility.
Splaktar
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerfreq2: mediumhotlist: components teamRelated to Angular CDK or Angular MaterialRelated to Angular CDK or Angular Materialtype: bug/fix