MCPcopy Index your code
hub / github.com/angular/angular / makeParamDecorator

Function makeParamDecorator

packages/core/src/util/decorators.ts:103–147  ·  view source on GitHub ↗
(
  name: string,
  props?: (...args: any[]) => any,
  parentClass?: any,
)

Source from the content-addressed store, hash-verified

101}
102
103export function makeParamDecorator(
104 name: string,
105 props?: (...args: any[]) => any,
106 parentClass?: any,
107): any {
108 return noSideEffects(() => {
109 const metaCtor = makeMetadataCtor(props);
110 function ParamDecoratorFactory(
111 this: unknown | typeof ParamDecoratorFactory,
112 ...args: any[]
113 ): any {
114 if (this instanceof ParamDecoratorFactory) {
115 metaCtor.apply(this, args);
116 return this;
117 }
118 const annotationInstance = new (<any>ParamDecoratorFactory)(...args);
119
120 (<any>ParamDecorator).annotation = annotationInstance;
121 return ParamDecorator;
122
123 function ParamDecorator(cls: any, unusedKey: any, index: number): any {
124 // Use of Object.defineProperty is important since it creates non-enumerable property which
125 // prevents the property is copied during subclassing.
126 const parameters = cls.hasOwnProperty(PARAMETERS)
127 ? (cls as any)[PARAMETERS]
128 : Object.defineProperty(cls, PARAMETERS, {value: []})[PARAMETERS];
129
130 // there might be gaps if some in between parameters do not have annotations.
131 // we pad with nulls.
132 while (parameters.length <= index) {
133 parameters.push(null);
134 }
135
136 (parameters[index] = parameters[index] || []).push(annotationInstance);
137 return cls;
138 }
139 }
140 if (parentClass) {
141 ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
142 }
143 ParamDecoratorFactory.prototype.ngMetadataName = name;
144 (<any>ParamDecoratorFactory).annotationCls = ParamDecoratorFactory;
145 return ParamDecoratorFactory;
146 });
147}
148
149export function makePropDecorator(
150 name: string,

Callers 2

metadata.tsFile · 0.90
metadata_attr.tsFile · 0.90

Calls 3

noSideEffectsFunction · 0.90
makeMetadataCtorFunction · 0.85
createMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…