88
99import { ChangeDetectionStrategy } from '../../change_detection/constants' ;
1010import { PipeTransform } from '../../change_detection/pipe_transform' ;
11+ import { Provider } from '../../core' ;
1112import { RendererType2 } from '../../render/api' ;
1213import { Type } from '../../type' ;
1314import { resolveRendererType2 } from '../../view/util' ;
1415
16+
17+
1518/**
1619 * Definition of what a template rendering function should look like.
1720 */
1821export type ComponentTemplate < T > = {
1922 ( ctx : T , creationMode : boolean ) : void ; ngPrivateData ?: never ;
2023} ;
2124
25+ /**
26+ * A subclass of `Type` which has a static `ngComponentDef`:`ComponentDef` field making it
27+ * consumable for rendering.
28+ */
2229export interface ComponentType < T > extends Type < T > { ngComponentDef : ComponentDef < T > ; }
2330
31+ /**
32+ * A subclass of `Type` which has a static `ngDirectiveDef`:`DirectiveDef` field making it
33+ * consumable for rendering.
34+ */
2435export interface DirectiveType < T > extends Type < T > { ngDirectiveDef : DirectiveDef < T > ; }
2536
2637export const enum DirectiveDefFlags { ContentQuery = 0b10 }
2738
39+ /**
40+ * A subclass of `Type` which has a static `ngPipeDef`:`PipeDef` field making it
41+ * consumable for rendering.
42+ */
2843export interface PipeType < T > extends Type < T > { ngPipeDef : PipeDef < T > ; }
2944
3045/**
31- * `DirectiveDef` is a compiled version of the Directive used by the renderer instructions.
46+ * Runtime link information for Directives.
47+ *
48+ * This is internal data structure used by the render to link
49+ * directives into templates.
50+ *
51+ * NOTE: Always use `defineDirective` function to create this object,
52+ * never create the object directly since the shape of this object
53+ * can change between versions.
54+ *
55+ * See: {@link defineDirective}
3256 */
3357export interface DirectiveDef < T > {
3458 /** Token representing the directive. Used by DI. */
@@ -59,11 +83,6 @@ export interface DirectiveDef<T> {
5983 */
6084 readonly outputs : { [ P in keyof T ] : P } ;
6185
62- /**
63- * A dictionary mapping the methods' minified names to their original unminified ones.
64- */
65- readonly methods : { [ P in keyof T ] : P } ;
66-
6786 /**
6887 * Name under which the directive is exported (for use with local references in template)
6988 */
@@ -104,6 +123,18 @@ export interface DirectiveDef<T> {
104123 onDestroy : ( ( ) => void ) | null ;
105124}
106125
126+ /**
127+ * Runtime link information for Components.
128+ *
129+ * This is internal data structure used by the render to link
130+ * components into templates.
131+ *
132+ * NOTE: Always use `defineComponent` function to create this object,
133+ * never create the object directly since the shape of this object
134+ * can change between versions.
135+ *
136+ * See: {@link defineComponent}
137+ */
107138export interface ComponentDef < T > extends DirectiveDef < T > {
108139 /**
109140 * The tag name which should be used by the component.
@@ -128,10 +159,31 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
128159
129160 /** Whether or not this component's ChangeDetectionStrategy is OnPush */
130161 readonly onPush : boolean ;
162+
163+ /**
164+ * Defines the set of injectable providers that are visible to a Directive and its content DOM
165+ * children.
166+ */
167+ readonly providers ?: Provider [ ] ;
168+
169+ /**
170+ * Defines the set of injectable providers that are visible to a Directive and its view DOM
171+ * children only.
172+ */
173+ readonly viewProviders ?: Provider [ ] ;
131174}
132175
133176/**
177+ * Runtime link information for Pipes.
178+ *
179+ * This is internal data structure used by the renderer to link
180+ * pipes into templates.
134181 *
182+ * NOTE: Always use `definePipe` function to create this object,
183+ * never create the object directly since the shape of this object
184+ * can change between versions.
185+ *
186+ * See: {@link definePipe}
135187 */
136188export interface PipeDef < T > {
137189 /**
@@ -154,30 +206,142 @@ export interface PipeDef<T> {
154206 onDestroy : ( ( ) => void ) | null ;
155207}
156208
157-
209+ /**
210+ * Arguments for `defineDirective`
211+ */
158212export interface DirectiveDefArgs < T > {
213+ /**
214+ * Directive type, needed to configure the injector.
215+ */
159216 type : Type < T > ;
217+
218+ /**
219+ * Factory method used to create an instance of directive.
220+ */
160221 factory : ( ) => T | [ T ] ;
222+
223+ /**
224+ * Static attributes to set on host element.
225+ *
226+ * Even indices: attribute name
227+ * Odd indices: attribute value
228+ */
161229 attributes ?: string [ ] ;
230+
231+ /**
232+ * A map of input names.
233+ *
234+ * The format is in: `{[actualPropertyName: string]:string}`.
235+ *
236+ * Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
237+ *
238+ * This allows the render to re-construct the minified and non-minified names
239+ * of properties.
240+ */
162241 inputs ?: { [ P in keyof T ] ?: string } ;
242+
243+ /**
244+ * TODO: Remove per https://github.com/angular/angular/issues/22591
245+ */
163246 inputsPropertyName ?: { [ P in keyof T ] ?: string } ;
247+
248+ /**
249+ * A map of output names.
250+ *
251+ * The format is in: `{[actualPropertyName: string]:string}`.
252+ *
253+ * Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
254+ *
255+ * This allows the render to re-construct the minified and non-minified names
256+ * of properties.
257+ */
164258 outputs ?: { [ P in keyof T ] ?: string } ;
165- methods ?: { [ P in keyof T ] ?: string } ;
259+
260+ /**
261+ * A list of optional features to apply.
262+ *
263+ * See: {@link NgOnChangesFeature}, {@link PublicFeature}
264+ */
166265 features ?: DirectiveDefFeature [ ] ;
266+
267+ /**
268+ * Function executed by the parent template to allow child directive to apply host bindings.
269+ */
167270 hostBindings ?: ( directiveIndex : number , elementIndex : number ) => void ;
271+
272+ /**
273+ * Defines the name that can be used in the template to assign this directive to a variable.
274+ *
275+ * See: {@link Directive.exportAs}
276+ */
168277 exportAs ?: string ;
169278}
170279
280+ /**
281+ * Arguments for `defineComponent`.
282+ */
171283export interface ComponentDefArgs < T > extends DirectiveDefArgs < T > {
284+ /**
285+ * HTML tag name to use in place where this component should be instantiated.
286+ */
172287 tag : string ;
288+
289+ /**
290+ * Template function use for rendering DOM.
291+ *
292+ * This function has following structure.
293+ *
294+ * ```
295+ * function Template<T>(ctx:T, creationMode: boolean) {
296+ * if (creationMode) {
297+ * // Contains creation mode instructions.
298+ * }
299+ * // Contains binding update instructions
300+ * }
301+ * ```
302+ *
303+ * Common instructions are:
304+ * Creation mode instructions:
305+ * - `elementStart`, `elementEnd`
306+ * - `text`
307+ * - `container`
308+ * - `listener`
309+ *
310+ * Binding update instructions:
311+ * - `bind`
312+ * - `elementAttribute`
313+ * - `elementProperty`
314+ * - `elementClass`
315+ * - `elementStyle`
316+ *
317+ */
173318 template : ComponentTemplate < T > ;
319+
320+ /**
321+ * A list of optional features to apply.
322+ *
323+ * See: {@link NgOnChancesFeature}, {@link PublicFeature}
324+ */
174325 features ?: ComponentDefFeature [ ] ;
326+
175327 rendererType ?: RendererType2 ;
328+
176329 changeDetection ?: ChangeDetectionStrategy ;
330+
331+ /**
332+ * Defines the set of injectable objects that are visible to a Directive and its light DOM
333+ * children.
334+ */
335+ providers ?: Provider [ ] ;
336+
337+ /**
338+ * Defines the set of injectable objects that are visible to its view DOM children.
339+ */
340+ viewProviders ?: Provider [ ] ;
177341}
178342
179343export type DirectiveDefFeature = < T > ( directiveDef : DirectiveDef < T > ) => void ;
180- export type ComponentDefFeature = < T > ( directiveDef : DirectiveDef < T > ) => void ;
344+ export type ComponentDefFeature = < T > ( componentDef : ComponentDef < T > ) => void ;
181345
182346// Note: This hack is necessary so we don't erroneously get a circular dependency
183347// failure based on types.
0 commit comments