Skip to content

Commit

Permalink
docs: review corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogarthyde committed Feb 28, 2019
1 parent 98ca106 commit 5bbe003
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 64 deletions.
14 changes: 0 additions & 14 deletions packages/core/src/di/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,6 @@ export interface AttributeDecorator {
*
* {@example core/ts/metadata/metadata.ts region='attributeFactory'}
*
* ### Example as ES5 annotation
*
* ```
* var MyComponent = function(title) {
* ...
* };
*
* MyComponent.annotations = [
* new ng.Component({...})
* ]
* MyComponent.parameters = [
* [new ng.Attribute('title')]
* ]
* ```
*/
(name: string): any;
new (name: string): Attribute;
Expand Down
99 changes: 49 additions & 50 deletions packages/core/src/metadata/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectionStrategy} from '../change_detection/constants';
import {Provider} from '../di';
import {Type} from '../interface/type';
import {NG_BASE_DEF} from '../render3/fields';
import {compileComponent as render3CompileComponent, compileDirective as render3CompileDirective} from '../render3/jit/directive';
import {compilePipe as render3CompilePipe} from '../render3/jit/pipe';
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
import {noop} from '../util/noop';
import {fillProperties} from '../util/property';
import { ChangeDetectionStrategy } from '../change_detection/constants';
import { Provider } from '../di';
import { Type } from '../interface/type';
import { NG_BASE_DEF } from '../render3/fields';
import { compileComponent as render3CompileComponent, compileDirective as render3CompileDirective } from '../render3/jit/directive';
import { compilePipe as render3CompilePipe } from '../render3/jit/pipe';
import { TypeDecorator, makeDecorator, makePropDecorator } from '../util/decorators';
import { noop } from '../util/noop';
import { fillProperties } from '../util/property';

import {ViewEncapsulation} from './view';
import { ViewEncapsulation } from './view';



Expand Down Expand Up @@ -74,7 +74,7 @@ export interface DirectiveDecorator {
/**
* See the `Directive` decorator.
*/
new (obj: Directive): Directive;
new(obj: Directive): Directive;
}

/**
Expand Down Expand Up @@ -254,7 +254,7 @@ export interface Directive {
*
* @Annotation
*/
queries?: {[key: string]: any};
queries?: { [key: string]: any };

/**
* Maps class properties to host element bindings for properties,
Expand All @@ -278,7 +278,7 @@ export interface Directive {
* event. A handler method can refer to the `$event` local variable.
*
*/
host?: {[key: string]: string};
host?: { [key: string]: string };

/**
* If true, this directive/component will be skipped by the AOT compiler and so will always be
Expand All @@ -295,8 +295,8 @@ export interface Directive {
* @publicApi
*/
export const Directive: DirectiveDecorator = makeDecorator(
'Directive', (dir: Directive = {}) => dir, undefined, undefined,
(type: Type<any>, meta: Directive) => SWITCH_COMPILE_DIRECTIVE(type, meta));
'Directive', (dir: Directive = {}) => dir, undefined, undefined,
(type: Type<any>, meta: Directive) => SWITCH_COMPILE_DIRECTIVE(type, meta));

/**
* Component decorator interface
Expand All @@ -317,7 +317,7 @@ export interface ComponentDecorator {
*
* A component must belong to an NgModule in order for it to be available
* to another component or application. To make it a member of an NgModule,
* list it in the `declarations` field of the `@NgModule` metadata.
* list it in the `declarations` field of the `NgModule` metadata.
*
* Note that, in addition to these options for configuring a directive,
* you can control a component's runtime behavior by implementing
Expand Down Expand Up @@ -443,9 +443,9 @@ export interface ComponentDecorator {
*/
(obj: Component): TypeDecorator;
/**
* See the `@Component` decorator.
* See the `Component` decorator.
*/
new (obj: Component): Component;
new(obj: Component): Component;
}

/**
Expand Down Expand Up @@ -543,7 +543,7 @@ export interface Component extends Directive {
* Angular creates a {@link ComponentFactory} and stores it in the
* {@link ComponentFactoryResolver}.
*/
entryComponents?: Array<Type<any>|any[]>;
entryComponents?: Array<Type<any> | any[]>;

/**
* True to preserve or false to remove potentially superfluous whitespace characters
Expand All @@ -561,9 +561,9 @@ export interface Component extends Directive {
* @publicApi
*/
export const Component: ComponentDecorator = makeDecorator(
'Component', (c: Component = {}) => ({changeDetection: ChangeDetectionStrategy.Default, ...c}),
Directive, undefined,
(type: Type<any>, meta: Component) => SWITCH_COMPILE_COMPONENT(type, meta));
'Component', (c: Component = {}) => ({ changeDetection: ChangeDetectionStrategy.Default, ...c }),
Directive, undefined,
(type: Type<any>, meta: Component) => SWITCH_COMPILE_COMPONENT(type, meta));

/**
* Type of the Pipe decorator / constructor function.
Expand All @@ -587,15 +587,15 @@ export interface PipeDecorator {
*
* A pipe must belong to an NgModule in order for it to be available
* to a template. To make it a member of an NgModule,
* list it in the `declarations` field of the `@NgModule` metadata.
* list it in the `declarations` field of the `NgModule` metadata.
*
*/
(obj: Pipe): TypeDecorator;

/**
* See the `Pipe` decorator.
*/
new (obj: Pipe): Pipe;
new(obj: Pipe): Pipe;
}

/**
Expand Down Expand Up @@ -628,8 +628,8 @@ export interface Pipe {
* @publicApi
*/
export const Pipe: PipeDecorator = makeDecorator(
'Pipe', (p: Pipe) => ({pure: true, ...p}), undefined, undefined,
(type: Type<any>, meta: Pipe) => SWITCH_COMPILE_PIPE(type, meta));
'Pipe', (p: Pipe) => ({ pure: true, ...p }), undefined, undefined,
(type: Type<any>, meta: Pipe) => SWITCH_COMPILE_PIPE(type, meta));


/**
Expand Down Expand Up @@ -676,12 +676,11 @@ export interface InputDecorator {
* <bank-account bankName="RBC" account-id="4747"></bank-account>
* `
* })
*
* class App {}
* ```
*/
(bindingPropertyName?: string): any;
new (bindingPropertyName?: string): any;
new(bindingPropertyName?: string): any;
}

/**
Expand Down Expand Up @@ -714,29 +713,29 @@ const initializeBaseDef = (target: any): void => {
};

/**
* Does the work of creating the `ngBaseDef` property for the `@Input` and `@Output` decorators.
* Does the work of creating the `ngBaseDef` property for the `Input` and `Output` decorators.
* @param key "inputs" or "outputs"
*/
const updateBaseDefFromIOProp = (getProp: (baseDef: {inputs?: any, outputs?: any}) => any) =>
(target: any, name: string, ...args: any[]) => {
const constructor = target.constructor;
const updateBaseDefFromIOProp = (getProp: (baseDef: { inputs?: any, outputs?: any }) => any) =>
(target: any, name: string, ...args: any[]) => {
const constructor = target.constructor;

if (!constructor.hasOwnProperty(NG_BASE_DEF)) {
initializeBaseDef(target);
}
if (!constructor.hasOwnProperty(NG_BASE_DEF)) {
initializeBaseDef(target);
}

const baseDef = constructor.ngBaseDef;
const defProp = getProp(baseDef);
defProp[name] = args[0] || name;
};
const baseDef = constructor.ngBaseDef;
const defProp = getProp(baseDef);
defProp[name] = args[0] || name;
};

/**
* @Annotation
* @publicApi
*/
export const Input: InputDecorator = makePropDecorator(
'Input', (bindingPropertyName?: string) => ({bindingPropertyName}), undefined,
updateBaseDefFromIOProp(baseDef => baseDef.inputs || {}));
'Input', (bindingPropertyName?: string) => ({ bindingPropertyName }), undefined,
updateBaseDefFromIOProp(baseDef => baseDef.inputs || {}));

/**
* Type of the Output decorator / constructor function.
Expand All @@ -755,11 +754,11 @@ export interface OutputDecorator {
* name of the bound property. By default, the original
* name of the bound property is used for output binding.
*
* See `@Input` decorator for an example of providing a binding name.
* See `Input` decorator for an example of providing a binding name.
*
*/
(bindingPropertyName?: string): any;
new (bindingPropertyName?: string): any;
new(bindingPropertyName?: string): any;
}

/**
Expand All @@ -779,8 +778,8 @@ export interface Output {
* @publicApi
*/
export const Output: OutputDecorator = makePropDecorator(
'Output', (bindingPropertyName?: string) => ({bindingPropertyName}), undefined,
updateBaseDefFromIOProp(baseDef => baseDef.outputs || {}));
'Output', (bindingPropertyName?: string) => ({ bindingPropertyName }), undefined,
updateBaseDefFromIOProp(baseDef => baseDef.outputs || {}));



Expand Down Expand Up @@ -820,7 +819,7 @@ export interface HostBindingDecorator {
*
*/
(hostPropertyName?: string): any;
new (hostPropertyName?: string): any;
new(hostPropertyName?: string): any;
}

/**
Expand All @@ -840,7 +839,7 @@ export interface HostBinding {
* @publicApi
*/
export const HostBinding: HostBindingDecorator =
makePropDecorator('HostBinding', (hostPropertyName?: string) => ({hostPropertyName}));
makePropDecorator('HostBinding', (hostPropertyName?: string) => ({ hostPropertyName }));


/**
Expand All @@ -850,11 +849,11 @@ export const HostBinding: HostBindingDecorator =
*/
export interface HostListenerDecorator {
/**
* Decorator that declares a CSS event to listen for,
* Decorator that declares a DOM event to listen for,
* and provides a handler method to run when that event occurs.
*/
(eventName: string, args?: string[]): any;
new (eventName: string, args?: string[]): any;
new(eventName: string, args?: string[]): any;
}

/**
Expand Down Expand Up @@ -906,7 +905,7 @@ export interface HostListener {
* @publicApi
*/
export const HostListener: HostListenerDecorator =
makePropDecorator('HostListener', (eventName?: string, args?: string[]) => ({eventName, args}));
makePropDecorator('HostListener', (eventName?: string, args?: string[]) => ({ eventName, args }));



Expand Down

0 comments on commit 5bbe003

Please sign in to comment.