66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { RendererType2 , Type } from '../core' ;
9+ import { RendererType2 } from '../render/api' ;
10+ import { Type } from '../type' ;
1011import { resolveRendererType2 } from '../view/util' ;
11- import { componentRefresh , diPublic } from './instructions' ;
1212
1313
1414
@@ -78,7 +78,7 @@ export interface DirectiveDef<T> {
7878 * @param directiveIndex index of the directive in the containing template
7979 * @param elementIndex index of an host element for a given directive.
8080 */
81- r ( this : DirectiveDef < T > , directiveIndex : number , elementIndex : number ) : void ;
81+ r ( directiveIndex : number , elementIndex : number ) : void ;
8282}
8383
8484export interface ComponentDef < T > extends DirectiveDef < T > {
@@ -93,7 +93,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
9393 * @param directiveIndex index of the directive in the containing template
9494 * @param elementIndex index of an host element for a given component.
9595 */
96- r ( this : ComponentDef < T > , directiveIndex : number , elementIndex : number ) : void ;
96+ r ( directiveIndex : number , elementIndex : number ) : void ;
9797
9898 /**
9999 * The tag name which should be used by the component.
@@ -120,7 +120,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
120120export interface DirectiveDefArgs < T > {
121121 type : Type < T > ;
122122 factory : ( ) => T ;
123- refresh ?: ( this : DirectiveDef < T > , directiveIndex : number , elementIndex : number ) => void ;
123+ refresh ?: ( directiveIndex : number , elementIndex : number ) => void ;
124124 inputs ?: { [ P in keyof T ] ?: string } ;
125125 outputs ?: { [ P in keyof T ] ?: string } ;
126126 methods ?: { [ P in keyof T ] ?: string } ;
@@ -130,80 +130,10 @@ export interface DirectiveDefArgs<T> {
130130export interface ComponentDefArgs < T > extends DirectiveDefArgs < T > {
131131 tag : string ;
132132 template : ComponentTemplate < T > ;
133- refresh ?: ( this : ComponentDef < T > , directiveIndex : number , elementIndex : number ) => void ;
133+ refresh ?: ( directiveIndex : number , elementIndex : number ) => void ;
134134 features ?: ComponentDefFeature [ ] ;
135135 rendererType ?: RendererType2 ;
136136}
137137
138138export type DirectiveDefFeature = < T > ( directiveDef : DirectiveDef < T > ) => void ;
139139export type ComponentDefFeature = < T > ( directiveDef : DirectiveDef < T > ) => void ;
140-
141- /**
142- * Create a component definition object.
143- *
144- *
145- * # Example
146- * ```
147- * class MyDirective {
148- * // Generated by Angular Template Compiler
149- * // [Symbol] syntax will not be supported by TypeScript until v2.7
150- * static [COMPONENT_DEF_SYMBOL] = defineComponent({
151- * ...
152- * });
153- * }
154- * ```
155- */
156- export function defineComponent < T > ( componentDefinition : ComponentDefArgs < T > ) : ComponentDef < T > {
157- const def = < ComponentDef < any > > {
158- type : componentDefinition . type ,
159- diPublic : null ,
160- n : componentDefinition . factory ,
161- tag : ( componentDefinition as ComponentDefArgs < T > ) . tag || null ! ,
162- template : ( componentDefinition as ComponentDefArgs < T > ) . template || null ! ,
163- r : componentDefinition . refresh || componentRefresh ,
164- inputs : invertObject ( componentDefinition . inputs ) ,
165- outputs : invertObject ( componentDefinition . outputs ) ,
166- methods : invertObject ( componentDefinition . methods ) ,
167- rendererType : resolveRendererType2 ( componentDefinition . rendererType ) || null ,
168- } ;
169- const feature = componentDefinition . features ;
170- feature && feature . forEach ( ( fn ) => fn ( def ) ) ;
171- return def ;
172- }
173-
174- export function NgOnChangesFeature < T > ( definition : DirectiveDef < T > ) {
175- // TODO: implement. See: https://app.asana.com/0/443577627818617/465170715764659
176- }
177-
178- export function PublicFeature < T > ( definition : DirectiveDef < T > ) {
179- definition . diPublic = diPublic ;
180- }
181-
182- const EMPTY = { } ;
183-
184- /** Swaps the keys and values of an object. */
185- function invertObject ( obj : any ) : any {
186- if ( obj == null ) return EMPTY ;
187- const newObj : any = { } ;
188- for ( let minifiedKey in obj ) {
189- newObj [ obj [ minifiedKey ] ] = minifiedKey ;
190- }
191- return newObj ;
192- }
193-
194- /**
195- * Create a directive definition object.
196- *
197- * # Example
198- * ```
199- * class MyDirective {
200- * // Generated by Angular Template Compiler
201- * // [Symbol] syntax will not be supported by TypeScript until v2.7
202- * static [DIRECTIVE_DEF_SYMBOL] = defineDirective({
203- * ...
204- * });
205- * }
206- * ```
207- */
208- export const defineDirective = defineComponent as < T > ( directiveDefinition : DirectiveDefArgs < T > ) =>
209- DirectiveDef < T > ;
0 commit comments