diff --git a/modules/angular2/src/change_detection/change_detection.ts b/modules/angular2/src/change_detection/change_detection.ts index 5e554702e0cf4..8d61656755d60 100644 --- a/modules/angular2/src/change_detection/change_detection.ts +++ b/modules/angular2/src/change_detection/change_detection.ts @@ -14,59 +14,67 @@ import {NullPipeFactory} from './pipes/null_pipe'; import {ChangeDetection, ProtoChangeDetector, ChangeDetectorDefinition} from './interfaces'; import {Inject, Injectable, OpaqueToken, Optional} from 'angular2/di'; import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection'; -import {CONST_EXPR, isPresent, BaseException} from 'angular2/src/facade/lang'; +import {CONST, CONST_EXPR, isPresent, BaseException} from 'angular2/src/facade/lang'; /** * Structural diffing for `Object`s and `Map`s. * * @exportedAs angular2/pipes */ -export var keyValDiff: List = [new KeyValueChangesFactory(), new NullPipeFactory()]; +export const keyValDiff: List = + CONST_EXPR([CONST_EXPR(new KeyValueChangesFactory()), CONST_EXPR(new NullPipeFactory())]); /** * Structural diffing for `Iterable` types such as `Array`s. * * @exportedAs angular2/pipes */ -export var iterableDiff: List = [new IterableChangesFactory(), new NullPipeFactory()]; +export const iterableDiff: List = + CONST_EXPR([CONST_EXPR(new IterableChangesFactory()), CONST_EXPR(new NullPipeFactory())]); /** * Async binding to such types as Observable. * * @exportedAs angular2/pipes */ -export var async: List = - [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()]; +export const async: List = CONST_EXPR([ + CONST_EXPR(new ObservablePipeFactory()), + CONST_EXPR(new PromisePipeFactory()), + CONST_EXPR(new NullPipeFactory()) +]); /** * Uppercase text transform. * * @exportedAs angular2/pipes */ -export var uppercase: List = [new UpperCaseFactory(), new NullPipeFactory()]; +export const uppercase: List = + CONST_EXPR([CONST_EXPR(new UpperCaseFactory()), CONST_EXPR(new NullPipeFactory())]); /** * Lowercase text transform. * * @exportedAs angular2/pipes */ -export var lowercase: List = [new LowerCaseFactory(), new NullPipeFactory()]; +export const lowercase: List = + CONST_EXPR([CONST_EXPR(new LowerCaseFactory()), CONST_EXPR(new NullPipeFactory())]); /** * Json stringify transform. * * @exportedAs angular2/pipes */ -export var json: List = [new JsonPipe(), new NullPipeFactory()]; +export const json: List = + CONST_EXPR([CONST_EXPR(new JsonPipe()), CONST_EXPR(new NullPipeFactory())]); -export var defaultPipes = { +export const defaultPipes = CONST_EXPR({ "iterableDiff": iterableDiff, "keyValDiff": keyValDiff, "async": async, "uppercase": uppercase, "lowercase": lowercase, "json": json -}; +}); /** * Map from {@link ChangeDetectorDefinition#id} to a factory method which takes a @@ -137,6 +145,7 @@ export class DynamicChangeDetection extends ChangeDetection { * @exportedAs angular2/change_detection */ @Injectable() +@CONST() export class JitChangeDetection extends ChangeDetection { constructor(public registry: PipeRegistry) { super(); } @@ -147,4 +156,4 @@ export class JitChangeDetection extends ChangeDetection { } } -export var defaultPipeRegistry: PipeRegistry = new PipeRegistry(defaultPipes); +export const defaultPipeRegistry: PipeRegistry = CONST_EXPR(new PipeRegistry(defaultPipes)); diff --git a/modules/angular2/src/change_detection/interfaces.ts b/modules/angular2/src/change_detection/interfaces.ts index 99e08d7fb2f4a..d25a4880d519d 100644 --- a/modules/angular2/src/change_detection/interfaces.ts +++ b/modules/angular2/src/change_detection/interfaces.ts @@ -1,4 +1,5 @@ import {List} from 'angular2/src/facade/collection'; +import {CONST} from 'angular2/src/facade/lang'; import {Locals} from './parser/locals'; import {BindingRecord} from './binding_record'; import {DirectiveRecord} from './directive_record'; @@ -29,6 +30,7 @@ import {DirectiveRecord} from './directive_record'; * ``` * @exportedAs angular2/change_detection */ +@CONST() export class ChangeDetection { createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector { return null; diff --git a/modules/angular2/src/change_detection/pipes/json_pipe.ts b/modules/angular2/src/change_detection/pipes/json_pipe.ts index 8d379b9246d98..e15c1b1237305 100644 --- a/modules/angular2/src/change_detection/pipes/json_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/json_pipe.ts @@ -1,4 +1,4 @@ -import {isBlank, isPresent, Json} from 'angular2/src/facade/lang'; +import {isBlank, isPresent, Json, CONST} from 'angular2/src/facade/lang'; import {Pipe, BasePipe, PipeFactory} from './pipe'; /** @@ -26,6 +26,7 @@ import {Pipe, BasePipe, PipeFactory} from './pipe'; * * @exportedAs angular2/pipes */ +@CONST() export class JsonPipe extends BasePipe { transform(value): string { return Json.stringify(value); } diff --git a/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts b/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts index 28a0fb72e066f..6d41e5c2208a0 100644 --- a/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts @@ -1,4 +1,4 @@ -import {isString, StringWrapper} from 'angular2/src/facade/lang'; +import {isString, StringWrapper, CONST} from 'angular2/src/facade/lang'; import {Pipe} from './pipe'; /** @@ -43,6 +43,7 @@ export class LowerCasePipe implements Pipe { /** * @exportedAs angular2/pipes */ +@CONST() export class LowerCaseFactory { supports(str): boolean { return isString(str); } diff --git a/modules/angular2/src/change_detection/pipes/pipe.ts b/modules/angular2/src/change_detection/pipes/pipe.ts index dd575c1c424b2..883665df99ca6 100644 --- a/modules/angular2/src/change_detection/pipes/pipe.ts +++ b/modules/angular2/src/change_detection/pipes/pipe.ts @@ -70,6 +70,7 @@ export interface Pipe { * } * ``` */ +@CONST() export class BasePipe implements Pipe { supports(obj): boolean { return true; } onDestroy(): void {} diff --git a/modules/angular2/src/change_detection/pipes/pipe_registry.ts b/modules/angular2/src/change_detection/pipes/pipe_registry.ts index c278c0f8512a3..ae9eeca173e6d 100644 --- a/modules/angular2/src/change_detection/pipes/pipe_registry.ts +++ b/modules/angular2/src/change_detection/pipes/pipe_registry.ts @@ -5,6 +5,7 @@ import {Injectable} from 'angular2/src/di/decorators'; import {ChangeDetectorRef} from '../change_detector_ref'; @Injectable() +@CONST() export class PipeRegistry { constructor(public config) {} diff --git a/modules/angular2/src/change_detection/pipes/promise_pipe.ts b/modules/angular2/src/change_detection/pipes/promise_pipe.ts index 00ffaf10a5d4b..3821484495a9a 100644 --- a/modules/angular2/src/change_detection/pipes/promise_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/promise_pipe.ts @@ -1,5 +1,5 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; -import {isBlank, isPresent, isPromise} from 'angular2/src/facade/lang'; +import {isBlank, isPresent, isPromise, CONST} from 'angular2/src/facade/lang'; import {Pipe, WrappedValue} from './pipe'; import {ChangeDetectorRef} from '../change_detector_ref'; @@ -80,6 +80,7 @@ export class PromisePipe implements Pipe { * * @exportedAs angular2/pipes */ +@CONST() export class PromisePipeFactory { supports(promise): boolean { return isPromise(promise); } diff --git a/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts b/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts index 8c9da28d7045f..78a9729184e7c 100644 --- a/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts @@ -1,4 +1,4 @@ -import {isString, StringWrapper} from 'angular2/src/facade/lang'; +import {isString, StringWrapper, CONST} from 'angular2/src/facade/lang'; import {Pipe} from './pipe'; /** @@ -43,6 +43,7 @@ export class UpperCasePipe implements Pipe { /** * @exportedAs angular2/pipes */ +@CONST() export class UpperCaseFactory { supports(str): boolean { return isString(str); } diff --git a/modules/angular2/src/core/application_tokens.ts b/modules/angular2/src/core/application_tokens.ts index d86cebaa5607c..441c5407bc8e1 100644 --- a/modules/angular2/src/core/application_tokens.ts +++ b/modules/angular2/src/core/application_tokens.ts @@ -1,4 +1,5 @@ import {OpaqueToken} from 'angular2/di'; +import {CONST_EXPR} from 'angular2/src/facade/lang'; -export var appComponentRefToken: OpaqueToken = new OpaqueToken('ComponentRef'); -export var appComponentTypeToken: OpaqueToken = new OpaqueToken('RootComponent'); +export const appComponentRefToken: OpaqueToken = CONST_EXPR(new OpaqueToken('ComponentRef')); +export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent'));