MCPcopy
hub / github.com/angular/angular / setClassMetadata

Function setClassMetadata

packages/core/src/render3/metadata.ts:87–121  ·  view source on GitHub ↗
(
  type: any,
  decorators: any[] | null,
  ctorParameters: (() => any[]) | null,
  propDecorators: {[field: string]: any} | null,
)

Source from the content-addressed store, hash-verified

85 * being tree-shaken away during production builds.
86 */
87export function setClassMetadata(
88 type: any,
89 decorators: any[] | null,
90 ctorParameters: (() => any[]) | null,
91 propDecorators: {[field: string]: any} | null,
92): void {
93 return noSideEffects(() => {
94 const clazz = type as TypeWithMetadata;
95
96 if (decorators !== null) {
97 if (clazz.hasOwnProperty('decorators') && clazz.decorators !== undefined) {
98 clazz.decorators.push(...decorators);
99 } else {
100 clazz.decorators = decorators;
101 }
102 }
103 if (ctorParameters !== null) {
104 // Rather than merging, clobber the existing parameters. If other projects exist which
105 // use tsickle-style annotations and reflect over them in the same way, this could
106 // cause issues, but that is vanishingly unlikely.
107 clazz.ctorParameters = ctorParameters;
108 }
109 if (propDecorators !== null) {
110 // The property decorator objects are merged as it is possible different fields have
111 // different decorator types. Decorators on individual fields are not merged, as it's
112 // also incredibly unlikely that a field will be decorated both with an Angular
113 // decorator and a non-Angular decorator that's also been downleveled.
114 if (clazz.hasOwnProperty('propDecorators') && clazz.propDecorators !== undefined) {
115 clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
116 } else {
117 clazz.propDecorators = propDecorators;
118 }
119 }
120 }) as never;
121}

Callers 8

metadata_spec.tsFile · 0.90
directive_spec.tsFile · 0.90
getAOTCompiledComponentFunction · 0.85
test_bed_spec.tsFile · 0.85
createComponentFunction · 0.85
createNgModuleFunction · 0.85

Calls 2

noSideEffectsFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…