chore(decorators): add types to decorators

Closes #5375
This commit is contained in:
Adam Bradley
2016-02-14 22:19:07 -06:00
parent 7f717b128b
commit a76808b4f1
3 changed files with 69 additions and 13 deletions

View File

@ -130,7 +130,8 @@ import {ViewController} from '../nav/view-controller';
title?: string, title?: string,
subTitle?: string, subTitle?: string,
cssClass?: string, cssClass?: string,
buttons?: Array<any> buttons?: Array<any>,
enableBackdropDismiss?: boolean
} = {}) { } = {}) {
return new ActionSheet(opts); return new ActionSheet(opts);
} }

View File

@ -1,4 +1,4 @@
import {Component, enableProdMode} from 'angular2/core'; import {Component, ChangeDetectionStrategy, ViewEncapsulation, enableProdMode, Type} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
import {TapClick} from '../components/tap-click/tap-click'; import {TapClick} from '../components/tap-click/tap-click';
import {ionicProviders} from '../config/bootstrap'; import {ionicProviders} from '../config/bootstrap';
@ -6,11 +6,40 @@ import {IONIC_DIRECTIVES} from '../config/directives';
const _reflect: any=Reflect; const _reflect: any=Reflect;
export interface AppMetadata {
prodMode?: boolean;
selector?: string;
inputs?: string[];
outputs?: string[];
properties?: string[];
events?: string[];
host?: {
[key: string]: string;
};
providers?: any[];
directives?: Array<Type | any[]>;
pipes?: Array<Type | any[]>;
exportAs?: string;
queries?: {
[key: string]: any;
};
template?: string;
templateUrl?: string;
moduleId?: string;
styleUrls?: string[];
styles?: string[];
changeDetection?: ChangeDetectionStrategy;
encapsulation?: ViewEncapsulation;
}
/** /**
* @name App * @name App
* @description * @description
* App is an Ionic decorator that bootstraps an application. It can be passed a number of arguments, that act as global config variables for the app. * App is an Ionic decorator that bootstraps an application. It can be passed a
* App can accept a `template` property that has an inline template or a `templateUrl` property that points to an external html template. * number of arguments that act as global config variables for the app.
* `@App` is similar to Angular's `@Component` in which it can accept a `template`
* property that has an inline template, or a `templateUrl` property that points
* to an external html template.
* *
* @usage * @usage
* ```ts * ```ts
@ -26,13 +55,14 @@ const _reflect: any=Reflect;
* } * }
* ``` * ```
* *
* @property {object} [config] - the app's {@link /docs/v2/api/config/Config/ Config} object * @property {object} [config] - the app's {@link /docs/v2/api/config/Config/ Config} object.
* @property {array} [providers] - any providers for your app * @property {boolean} [prodMode] - Enable Angular's production mode, which turns off assertions and other checks within the framework. Defaults to `false`.
* @property {string} [template] - the template to use for the app root * @property {array} [pipes] - any pipes for your app.
* @property {string} [templateUrl] - a relative URL pointing to the template to use for the app root * @property {array} [providers] - any providers for your app.
* * @property {string} [template] - the template to use for the app root.
* @property {string} [templateUrl] - a relative URL pointing to the template to use for the app root.
*/ */
export function App(args: any={}) { export function App(args: AppMetadata) {
return function(cls) { return function(cls) {
// get current annotations // get current annotations

View File

@ -1,8 +1,33 @@
import {Component} from 'angular2/core' import {Component, ChangeDetectionStrategy, ViewEncapsulation, Type} from 'angular2/core'
import {IONIC_DIRECTIVES} from '../config/directives'; import {IONIC_DIRECTIVES} from '../config/directives';
const _reflect: any=Reflect; const _reflect: any=Reflect;
export interface PageMetadata {
selector?: string;
inputs?: string[];
outputs?: string[];
properties?: string[];
events?: string[];
host?: {
[key: string]: string;
};
providers?: any[];
directives?: Array<Type | any[]>;
pipes?: Array<Type | any[]>;
exportAs?: string;
queries?: {
[key: string]: any;
};
template?: string;
templateUrl?: string;
moduleId?: string;
styleUrls?: string[];
styles?: string[];
changeDetection?: ChangeDetectionStrategy;
encapsulation?: ViewEncapsulation;
}
/** /**
* @name Page * @name Page
* @description * @description
@ -71,7 +96,7 @@ const _reflect: any=Reflect;
* *
* For more information on how pages are created, see the [NavController API reference](../../components/nav/NavController/#creating_pages) * For more information on how pages are created, see the [NavController API reference](../../components/nav/NavController/#creating_pages)
*/ */
export function Page(config: any={}) { export function Page(config: PageMetadata) {
return function(cls) { return function(cls) {
config.selector = 'ion-page'; config.selector = 'ion-page';
config.directives = config.directives ? config.directives.concat(IONIC_DIRECTIVES) : IONIC_DIRECTIVES; config.directives = config.directives ? config.directives.concat(IONIC_DIRECTIVES) : IONIC_DIRECTIVES;