diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 97f750865b..4ced8d405c 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -37,7 +37,8 @@ export class CompileMetadataResolver { constructor( private _ngModuleResolver: NgModuleResolver, private _directiveResolver: DirectiveResolver, private _pipeResolver: PipeResolver, private _config: CompilerConfig, - private _console: Console, private _schemaRegistry: ElementSchemaRegistry, private _reflector: ReflectorReader = reflector) {} + private _console: Console, private _schemaRegistry: ElementSchemaRegistry, + private _reflector: ReflectorReader = reflector) {} private sanitizeTokenName(token: any): string { let identifier = stringify(token); diff --git a/modules/@angular/core/src/metadata.ts b/modules/@angular/core/src/metadata.ts index f7b792ac86..d8c053e3aa 100644 --- a/modules/@angular/core/src/metadata.ts +++ b/modules/@angular/core/src/metadata.ts @@ -15,14 +15,14 @@ import {ChangeDetectionStrategy} from '../src/change_detection/change_detection' import {AnimationEntryMetadata} from './animation/metadata'; import {AttributeMetadata, ContentChildMetadata, ContentChildrenMetadata, QueryMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata} from './metadata/di'; -import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata} from './metadata/directives'; -import {ModuleWithProviders, NgModuleMetadata, SchemaMetadata} from './metadata/ng_module'; +import {ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata, PipeMetadataType} from './metadata/directives'; +import {ModuleWithProviders, NgModuleMetadata, NgModuleMetadataType, SchemaMetadata} from './metadata/ng_module'; import {ViewEncapsulation} from './metadata/view'; export {ANALYZE_FOR_ENTRY_COMPONENTS, AttributeMetadata, ContentChildMetadata, ContentChildrenMetadata, QueryMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata} from './metadata/di'; -export {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata} from './metadata/directives'; +export {ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata, PipeMetadataType} from './metadata/directives'; export {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from './metadata/lifecycle_hooks'; -export {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModuleMetadata, SchemaMetadata} from './metadata/ng_module'; +export {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModuleMetadata, NgModuleMetadataType, SchemaMetadata} from './metadata/ng_module'; export {ViewEncapsulation, ViewMetadata} from './metadata/view'; import {makeDecorator, makeParamDecorator, makePropDecorator, TypeDecorator,} from './util/decorators'; @@ -90,28 +90,8 @@ export interface NgModuleDecorator extends TypeDecorator {} * @stable */ export interface DirectiveMetadataFactory { - (obj: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - queries?: {[key: string]: any} - }): DirectiveDecorator; - new (obj: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - queries?: {[key: string]: any} - }): DirectiveMetadata; + (obj: DirectiveMetadataType): DirectiveDecorator; + new (obj: DirectiveMetadataType): DirectiveMetadata; } /** @@ -148,54 +128,8 @@ export interface DirectiveMetadataFactory { * @stable */ export interface ComponentMetadataFactory { - (obj: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - moduleId?: string, - queries?: {[key: string]: any}, - viewProviders?: any[], - changeDetection?: ChangeDetectionStrategy, - templateUrl?: string, - template?: string, - styleUrls?: string[], - styles?: string[], - animations?: AnimationEntryMetadata[], - directives?: Array, - pipes?: Array, - encapsulation?: ViewEncapsulation, - interpolation?: [string, string], - entryComponents?: Array - }): ComponentDecorator; - new (obj: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - moduleId?: string, - queries?: {[key: string]: any}, - viewProviders?: any[], - changeDetection?: ChangeDetectionStrategy, - templateUrl?: string, - template?: string, - styleUrls?: string[], - styles?: string[], - animations?: AnimationEntryMetadata[], - directives?: Array, - pipes?: Array, - encapsulation?: ViewEncapsulation, - interpolation?: [string, string], - entryComponents?: Array - }): ComponentMetadata; + (obj: ComponentMetadataType): ComponentDecorator; + new (obj: ComponentMetadataType): ComponentMetadata; } /** @@ -337,8 +271,8 @@ export interface ViewChildMetadataFactory { * @stable */ export interface PipeMetadataFactory { - (obj: {name: string, pure?: boolean}): any; - new (obj: {name: string, pure?: boolean}): any; + (obj: PipeMetadataType): any; + new (obj: PipeMetadataType): any; } /** @@ -387,22 +321,8 @@ export interface HostListenerMetadataFactory { * @experimental */ export interface NgModuleMetadataFactory { - (obj?: { - providers?: any[], - declarations?: Array, - imports?: Array, - exports?: Array, - entryComponents?: Array, - schemas?: Array - }): NgModuleDecorator; - new (obj?: { - providers?: any[], - declarations?: Array, - imports?: Array, - exports?: Array, - entryComponents?: Array, - schemas?: Array - }): NgModuleMetadata; + (obj?: NgModuleMetadataType): NgModuleDecorator; + new (obj?: NgModuleMetadataType): NgModuleMetadata; } // TODO(alexeagle): remove the duplication of this doc. It is copied from ComponentMetadata. diff --git a/modules/@angular/core/src/metadata/directives.ts b/modules/@angular/core/src/metadata/directives.ts index 056e0ffc27..673ef3e67c 100644 --- a/modules/@angular/core/src/metadata/directives.ts +++ b/modules/@angular/core/src/metadata/directives.ts @@ -13,6 +13,21 @@ import {Type, isPresent} from '../facade/lang'; import {ViewEncapsulation} from './view'; +/** + * Interface for creating {@link DirectiveMetadata} + * @experimental + */ +export interface DirectiveMetadataType { + selector?: string; + properties?: string[]; + inputs?: string[]; + events?: string[]; + outputs?: string[]; + host?: {[key: string]: string}; + providers?: any[]; + exportAs?: string; + queries?: {[key: string]: any}; +} /** * Directives allow you to attach behavior to elements in the DOM. @@ -396,7 +411,7 @@ import {ViewEncapsulation} from './view'; * @ts2dart_const * @stable */ -export class DirectiveMetadata extends InjectableMetadata { +export class DirectiveMetadata extends InjectableMetadata implements DirectiveMetadataType { /** * The CSS selector that triggers the instantiation of a directive. * @@ -749,17 +764,9 @@ export class DirectiveMetadata extends InjectableMetadata { */ queries: {[key: string]: any}; - constructor({selector, inputs, outputs, properties, events, host, providers, exportAs, queries}: { - selector?: string, - inputs?: string[], - outputs?: string[], - /** @deprecated */ properties?: string[], - /** @deprecated */ events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - queries?: {[key: string]: any} - } = {}) { + constructor( + {selector, inputs, outputs, properties, events, host, providers, exportAs, + queries}: DirectiveMetadataType = {}) { super(); this.selector = selector; this._inputs = inputs; @@ -773,6 +780,26 @@ export class DirectiveMetadata extends InjectableMetadata { } } +/** + * Interface for creating {@link ComponentMetadataType} + * @experimental + */ +export interface ComponentMetadataType extends DirectiveMetadataType { + changeDetection?: ChangeDetectionStrategy; + viewProviders?: any[]; + moduleId?: string; + templateUrl?: string; + template?: string; + styleUrls?: string[]; + styles?: string[]; + animations?: AnimationEntryMetadata[]; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + interpolation?: [string, string]; + entryComponents?: Array; +} + /** * Declare reusable UI building blocks for an application. * @@ -800,7 +827,7 @@ export class DirectiveMetadata extends InjectableMetadata { * @ts2dart_const * @stable */ -export class ComponentMetadata extends DirectiveMetadata { +export class ComponentMetadata extends DirectiveMetadata implements ComponentMetadataType { /** * Defines the used change detection strategy. * @@ -999,36 +1026,28 @@ export class ComponentMetadata extends DirectiveMetadata { */ entryComponents: Array; - constructor( - {selector, inputs, outputs, properties, events, host, exportAs, moduleId, providers, - viewProviders, changeDetection = ChangeDetectionStrategy.Default, queries, templateUrl, - template, styleUrls, styles, animations, directives, pipes, encapsulation, interpolation, - /** @deprecated use entryComponents instead! */ - precompile, entryComponents}: { - selector?: string, - inputs?: string[], - outputs?: string[], - /** @deprecated */ properties?: string[], - /** @deprecated */ events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - moduleId?: string, - viewProviders?: any[], - queries?: {[key: string]: any}, - changeDetection?: ChangeDetectionStrategy, - templateUrl?: string, - template?: string, - styleUrls?: string[], - styles?: string[], - animations?: AnimationEntryMetadata[], - directives?: Array, - pipes?: Array, - encapsulation?: ViewEncapsulation, - interpolation?: [string, string], - precompile?: Array, - entryComponents?: Array - } = {}) { + constructor({selector, + inputs, + outputs, + properties, + events, + host, + exportAs, + moduleId, + providers, + viewProviders, + changeDetection = ChangeDetectionStrategy.Default, + queries, + templateUrl, + template, + styleUrls, + styles, + animations, + directives, + pipes, + encapsulation, + interpolation, + entryComponents}: ComponentMetadataType = {}) { super({ selector: selector, inputs: inputs, @@ -1053,10 +1072,19 @@ export class ComponentMetadata extends DirectiveMetadata { this.moduleId = moduleId; this.animations = animations; this.interpolation = interpolation; - this.entryComponents = precompile ? precompile : entryComponents; + this.entryComponents = entryComponents; } } +/** + * Interface for creating {@link PipeMetadata} + * @experimental + */ +export interface PipeMetadataType { + name: string; + pure?: boolean; +} + /** * Declare reusable pipe function. * @@ -1070,12 +1098,12 @@ export class ComponentMetadata extends DirectiveMetadata { * @ts2dart_const * @stable */ -export class PipeMetadata extends InjectableMetadata { +export class PipeMetadata extends InjectableMetadata implements PipeMetadataType { name: string; /** @internal */ _pure: boolean; - constructor({name, pure}: {name: string, pure?: boolean}) { + constructor({name, pure}: PipeMetadataType) { super(); this.name = name; this._pure = pure; diff --git a/modules/@angular/core/src/metadata/ng_module.ts b/modules/@angular/core/src/metadata/ng_module.ts index 8c131761f5..8f080c9c51 100644 --- a/modules/@angular/core/src/metadata/ng_module.ts +++ b/modules/@angular/core/src/metadata/ng_module.ts @@ -36,11 +36,24 @@ export const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata = { name: 'custom-elements' }; +/** + * Interface for creating {@link NgModuleMetadata} + * @experimental + */ +export interface NgModuleMetadataType { + providers?: any[]; + declarations?: Array; + imports?: Array; + exports?: Array; + entryComponents?: Array; + schemas?: Array; +} + /** * Declares an Angular Module. * @experimental */ -export class NgModuleMetadata extends InjectableMetadata { +export class NgModuleMetadata extends InjectableMetadata implements NgModuleMetadataType { /** * Defines the set of injectable objects that are available in the injector * of this module. @@ -133,14 +146,9 @@ export class NgModuleMetadata extends InjectableMetadata { schemas: Array; - constructor({providers, declarations, imports, exports, entryComponents, schemas}: { - providers?: any[], - declarations?: Array, - imports?: Array, - exports?: Array, - entryComponents?: Array, - schemas?: Array - } = {}) { + constructor( + {providers, declarations, imports, exports, entryComponents, + schemas}: NgModuleMetadataType = {}) { super(); this._providers = providers; this.declarations = declarations;