X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/angular2/src/core/facade/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function CONST_EXPR<T>(expr: T): T {
return expr;
}

export function CONST(): ClassDecorator {
export function CONST(): ClassDecorator & PropertyDecorator {
return (target) => target;
}

Expand Down
8 changes: 7 additions & 1 deletion modules/angular2/src/core/util/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ export interface ClassDefinition {
*
* See {@link Class} for example of usage.
*/
constructor: (Function | any[]);
constructor: Function | any[];

/**
* Other methods on the class. Note that values should have type 'Function' but TS requires
* all properties to have a narrower type than the index signature.
*/
[x: string]: Type | Function | any[];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/test/core/forms/directives_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function main() {
});

it("should throw when more than one custom accessor is provided", () => {
var customAccessor = new SpyValueAccessor();
var customAccessor: ControlValueAccessor = <any>new SpyValueAccessor();
expect(() => selectValueAccessor(dir, [customAccessor, customAccessor])).toThrowError();
});
});
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/test/core/forms/model_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function main() {
{"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}});

g.controls["nested"].controls["two"].updateValue("333");
(<Control>(g.controls["nested"].find("two"))).updateValue("333");

expect(g.value).toEqual({"one": "111", "nested": {"two": "333"}});
});
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/test/core/zone/ng_zone_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
xit,
Log,
isInInnerZone,
browserDetection,
TIMEOUT_INTERVAL_FOR_SLOW_BROWSERS
browserDetection
} from 'angular2/test_lib';

import {PromiseCompleter, PromiseWrapper, TimerWrapper} from 'angular2/src/core/facade/async';
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2_material/src/components/button/button.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Component, View, LifecycleEvent, ViewEncapsulation, OnChanges} from 'angular2/angular2';
import {Component, View, ViewEncapsulation, OnChanges} from 'angular2/angular2';

import {TimerWrapper} from 'angular2/src/core/facade/async';
import {isPresent} from 'angular2/src/core/facade/lang';


// TODO(jelbourn): Ink ripples.
// TODO(jelbourn): Make the `isMosueDown` stuff done with one global listener.
// TODO(jelbourn): Make the `isMouseDown` stuff done with one global listener.

@Component({
selector: '[md-button]:not(a), [md-fab]:not(a), [md-raised-button]:not(a)',
Expand Down
9 changes: 1 addition & 8 deletions modules/angular2_material/src/components/input/input.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Directive,
LifecycleEvent,
Attribute,
Host,
SkipSelf,
AfterContentChecked
} from 'angular2/angular2';
import {Directive, Attribute, Host, SkipSelf, AfterContentChecked} from 'angular2/angular2';

import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Component,
LifecycleEvent,
View,
ViewEncapsulation,
Attribute,
OnChanges
} from 'angular2/angular2';
import {Component, View, ViewEncapsulation, Attribute, OnChanges} from 'angular2/angular2';
import {CONST} from 'angular2/src/core/facade/lang';
import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
import {Math} from 'angular2/src/core/facade/math';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Component,
View,
ViewEncapsulation,
LifecycleEvent,
Host,
SkipSelf,
Attribute,
Expand Down
3 changes: 1 addition & 2 deletions modules/benchmarks/src/compiler/compiler_benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ function measureWrapper(func, desc) {

class MultiplyViewResolver extends ViewResolver {
_multiplyBy: number;
_cache: Map<Type, ViewMetadata>;
_cache = new Map<Type, ViewMetadata>();

constructor(multiple: number, components: Type[]) {
super();
this._multiplyBy = multiple;
this._cache = new Map();
ListWrapper.forEach(components, (c) => this._fillCache(c));
}

Expand Down
1 change: 1 addition & 0 deletions modules/benchmarks_external/src/tree/react/react.min.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export var createElement: Function;
export var render: Function;
export var createClass: Function;
4 changes: 2 additions & 2 deletions modules/examples/src/web_workers/message_broker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ document.getElementById("send_echo")
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
// TODO(jteplitz602): Replace default constructors with real constructors
// once they're in the .d.ts file (#3926)
var args = new UiArguments();
var args = new UiArguments("echo");
args.method = "echo";
var fnArg = new FnArg();
var fnArg = new FnArg(val, PRIMITIVE);
fnArg.value = val;
fnArg.type = PRIMITIVE;
args.args = [fnArg];
Expand Down
47 changes: 47 additions & 0 deletions modules/upgrade/src/angular.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
declare namespace angular {
function module(prefix: string, dependencies?: string[]);
interface IModule {
directive(selector: string, factory: any): IModule;
value(key: string, value: any): IModule;
run(a: any);
}
interface ICompileService {
(element: Element): (IScope) => void;
}
interface IRootScopeService {
$new(): IScope;
$watch(expr: any, fn?: (a1?: any, a2?: any) => void);
$apply(): any;
$apply(exp: string): any;
$apply(exp: (scope: IScope) => any): any;
}
interface IScope extends IRootScopeService {}
interface IAngularBootstrapConfig {}
interface IDirective {}
interface IAttributes {
$observe(attr: string, fn: (v: string) => void);
}
interface ITranscludeFunction {}
interface IAugmentedJQuery {
bind(name: string, fn: () => void);
}
interface IParseService {
(expression: string): ICompiledExpression;
}
interface ICompiledExpression {
assign(context: any, value: any): any;
}
function element(e: Element);
function bootstrap(e: Element, modules: IModule[], config: IAngularBootstrapConfig);

namespace auto {
interface IInjectorService {
get(key: string): any;
}
}
var version: {major: number};
}

interface Function {
$inject?: string[];
}
5 changes: 3 additions & 2 deletions modules/upgrade/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export interface AttrProp {
}

export interface ComponentInfo {
type: Type;
selector: string;
inputs: AttrProp[];
outputs: AttrProp[];
}

export function getComponentInfo(type: Type): string {
export function getComponentInfo(type: Type): ComponentInfo {
var resolvedMetadata: DirectiveMetadata = directiveResolver.resolve(type);
var selector = resolvedMetadata.selector;
if (!selector.match(COMPONENT_SELECTOR)) {
Expand Down Expand Up @@ -59,7 +60,7 @@ export function parseFields(names: string[]): AttrProp[] {
attr: attr,
bracketAttr: `[${attr}]`,
parenAttr: `(${attr})`,
bracketParenAttr: `[(${attr})]`
bracketParenAttr: `[(${attr})]`,
onAttr: `on${capitalAttr}`,
bindAttr: `bind${capitalAttr}`,
bindonAttr: `bindon${capitalAttr}`
Expand Down
13 changes: 5 additions & 8 deletions modules/upgrade/src/upgrade_module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
///<reference path="../typings/angularjs/angular.d.ts"/>
///<reference path="./angular.d.ts"/>

import {
platform,
PlatformRef,
ApplicationRef,
ComponentRef,
bind,
Directive,
Expand Down Expand Up @@ -62,7 +60,7 @@ export class UpgradeModule {
this.componentTypes.push(type);
var info: ComponentInfo = getComponentInfo(type);
var factory: Function = ng1ComponentDirective(info, `${this.idPrefix}${info.selector}_c`);
this.ng1Module.directive(info.selector, <any[]>factory);
this.ng1Module.directive(info.selector, <any>factory);
return this;
}

Expand Down Expand Up @@ -175,7 +173,7 @@ function ng1ComponentDirective(info: ComponentInfo, idPrefix: string): Function
class Ng2ComponentFacade {
component: any = null;
inputChangeCount: number = 0;
inputChanges: StringMap<string, SimpleChange> = null;
inputChanges: {[key: string]: SimpleChange} = null;
hostViewRef: HostViewRef = null;
changeDetector: ChangeDetectorRef = null;
componentScope: angular.IScope;
Expand Down Expand Up @@ -215,7 +213,7 @@ class Ng2ComponentFacade {
prevValue = value;
}
this.component[prop] = value;
}
};
})(input.prop);
attrs.$observe(input.attr, observeFn);
} else if (attrs.hasOwnProperty(input.bindAttr)) {
Expand Down Expand Up @@ -284,8 +282,7 @@ class Ng2ComponentFacade {
((getter) => (value) => getter(this.scope, {$event: value}))(getter)
});
} else {
throw new Error(
`Missing emitter '${output.prop}' on component '${this.input.selector}'!`);
throw new Error(`Missing emitter '${output.prop}' on component '${this.info.selector}'!`);
}
}
}
Expand Down
45 changes: 22 additions & 23 deletions modules/upgrade/test/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'angular2/test_lib';

import {Component, View, Inject, EventEmitter} from 'angular2/angular2';
import {createUpgradeModule, UpgradeModule, bootstrapHybrid} from 'upgrade/upgrade';
import {createUpgradeModule, UpgradeModule} from 'upgrade/upgrade';

export function main() {
describe('upgrade: ng1 to ng2', () => {
Expand Down Expand Up @@ -56,7 +56,8 @@ export function main() {
}));

describe('scope/component change-detection', () => {
it('should interleve scope and component expressions', inject([AsyncTestCompleter], (async) {
it('should interleave scope and component expressions',
inject([AsyncTestCompleter], (async) => {
var log = [];
var l = function(value) {
log.push(value);
Expand Down Expand Up @@ -93,7 +94,7 @@ export function main() {
});

describe('binding from ng1 to ng2', () => {
it('should bind properties, events', inject([AsyncTestCompleter], (async) {
it('should bind properties, events', inject([AsyncTestCompleter], (async) => {
var upgrMod: UpgradeModule = createUpgradeModule();
upgrMod.ng1Module.run(($rootScope) => {
$rootScope.dataA = 'A';
Expand Down Expand Up @@ -133,26 +134,24 @@ export function main() {
this.twoWayBEmitter = new EventEmitter();
},
onChanges: function(changes) {
var assert =
(prop, value) => {
if (this[prop] != value) {
throw new Error(
`Expected: '${prop}' to be '${value}' but was '${this[prop]}'`);
}
}

var assertChange =
(prop, value) => {
assert(prop, value);
if (!changes[prop]) {
throw new Error(`Changes record for '${prop}' not found.`);
}
var actValue = changes[prop].currentValue;
if (actValue != value) {
throw new Error(
`Expected changes record for'${prop}' to be '${value}' but was '${actValue}'`);
}
}
var assert = (prop, value) => {
if (this[prop] != value) {
throw new Error(
`Expected: '${prop}' to be '${value}' but was '${this[prop]}'`);
}
};

var assertChange = (prop, value) => {
assert(prop, value);
if (!changes[prop]) {
throw new Error(`Changes record for '${prop}' not found.`);
}
var actValue = changes[prop].currentValue;
if (actValue != value) {
throw new Error(
`Expected changes record for'${prop}' to be '${value}' but was '${actValue}'`);
}
};

switch (this.onChangesCount++) {
case 0:
Expand Down
12 changes: 0 additions & 12 deletions modules/upgrade/tsd.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"preinstall": "node tools/npm/check-node-modules --purge",
"postinstall": "node tools/npm/copy-npm-shrinkwrap && node tools/chromedriverpatch.js && webdriver-manager update && bower install && gulp pubget.dart && tsd reinstall --overwrite --clean --config modules/angular2/tsd.json && tsd reinstall --overwrite --clean --config tools/tsd.json && tsd reinstall --overwrite --config modules/upgrade/tsd.json",
"postinstall": "node tools/npm/copy-npm-shrinkwrap && node tools/chromedriverpatch.js && webdriver-manager update && bower install && gulp pubget.dart && tsd reinstall --overwrite --clean --config modules/angular2/tsd.json && tsd reinstall --overwrite --clean --config tools/tsd.json",
"test": "gulp test.all.js && gulp test.all.dart"
},
"dependencies": {
Expand Down
7 changes: 4 additions & 3 deletions tools/broccoli/trees/browser_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,21 @@ module.exports = function makeBrowserTree(options, destinationPath) {
});

// Use TypeScript to transpile the *.ts files to ES5
var es5Tree = compileWithTypescript(es5ModulesTree, {
var typescriptOptions = {
allowNonTsExtensions: false,
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
mapRoot: '', // force sourcemaps to use relative path
module: 'CommonJS',
moduleResolution: 1 /* classic */,
noEmitOnError: false,
noEmitOnError: true,
rootDir: '.',
sourceMap: true,
sourceRoot: '.',
target: 'ES5'
});
};
var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions);

// Now we add a few more files to the es6 tree that the es5 tree should not see
var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: 'angular2'});
Expand Down
X Tutup