diff --git a/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html b/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html index 0746331b5e..a19f0c41e0 100644 --- a/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html +++ b/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html @@ -20,7 +20,3 @@ declare module ng { interface InjectableReference {} } {% endblock %} - -declare module "angular2/angular2" { - export = ng; -} diff --git a/docs/typescript-definition-package/templates/type-definition.template.html b/docs/typescript-definition-package/templates/type-definition.template.html index 4ebceffaa0..33cb3c961b 100644 --- a/docs/typescript-definition-package/templates/type-definition.template.html +++ b/docs/typescript-definition-package/templates/type-definition.template.html @@ -65,8 +65,8 @@ declare module ng { {% endfor %} } -{% endfor %} - -declare module "angular2/angular2" { +declare module "{$ alias $}" { export = ng; } + +{% endfor %} diff --git a/gulpfile.js b/gulpfile.js index f7efa9374a..e1a9a59482 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -761,7 +761,7 @@ gulp.task('!pre.test.typings', ['docs/typings'], function() { // ----------------- gulp.task('test.typings', ['!pre.test.typings'], function() { - return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/angular2.d.ts']) + return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/*.d.ts']) .pipe(tsc({target: 'ES5', module: 'commonjs', experimentalDecorators: true, noImplicitAny: true, diff --git a/modules/angular2/router.ts b/modules/angular2/router.ts index a99e5f4da6..33c29c510e 100644 --- a/modules/angular2/router.ts +++ b/modules/angular2/router.ts @@ -16,8 +16,10 @@ export {HTML5LocationStrategy} from './src/router/html5_location_strategy'; export {Location, appBaseHrefToken} from './src/router/location'; export {Pipeline} from './src/router/pipeline'; export * from './src/router/route_config_decorator'; +export * from './src/router/route_definition'; export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces'; export {CanActivate} from './src/router/lifecycle_annotations'; +export {Instruction} from './src/router/instruction'; import {LocationStrategy} from './src/router/location_strategy'; import {HTML5LocationStrategy} from './src/router/html5_location_strategy'; diff --git a/modules/angular2/src/router/lifecycle_annotations.ts b/modules/angular2/src/router/lifecycle_annotations.ts index 112017ff89..8532530dfb 100644 --- a/modules/angular2/src/router/lifecycle_annotations.ts +++ b/modules/angular2/src/router/lifecycle_annotations.ts @@ -5,6 +5,8 @@ import {makeDecorator} from 'angular2/src/util/decorators'; import {CanActivate as CanActivateAnnotation} from './lifecycle_annotations_impl'; +import {Promise} from 'angular2/src/facade/async'; +import {Instruction} from 'angular2/src/router/instruction'; export { canReuse, @@ -14,4 +16,6 @@ export { onDeactivate } from './lifecycle_annotations_impl'; -export var CanActivate = makeDecorator(CanActivateAnnotation); +export var CanActivate: + (hook: (next: Instruction, prev: Instruction) => Promise| boolean) => ClassDecorator = + makeDecorator(CanActivateAnnotation); diff --git a/modules/angular2/src/router/location_strategy.ts b/modules/angular2/src/router/location_strategy.ts index f89c7ef5be..ec008ee85b 100644 --- a/modules/angular2/src/router/location_strategy.ts +++ b/modules/angular2/src/router/location_strategy.ts @@ -9,6 +9,6 @@ export class LocationStrategy { pushState(ctx: any, title: string, url: string): void { throw _abstract(); } forward(): void { throw _abstract(); } back(): void { throw _abstract(); } - onPopState(fn: (_) => any): void { throw _abstract(); } + onPopState(fn: (_: any) => any): void { throw _abstract(); } getBaseHref(): string { throw _abstract(); } } diff --git a/modules/angular2/src/router/route_config_decorator.ts b/modules/angular2/src/router/route_config_decorator.ts index c1b9261d62..955664de94 100644 --- a/modules/angular2/src/router/route_config_decorator.ts +++ b/modules/angular2/src/router/route_config_decorator.ts @@ -1,5 +1,7 @@ -import {RouteConfig as RouteConfigAnnotation} from './route_config_impl'; +import {RouteConfig as RouteConfigAnnotation, RouteDefinition} from './route_config_impl'; import {makeDecorator} from 'angular2/src/util/decorators'; +import {List} from 'angular2/src/facade/collection'; export {Route, Redirect, AsyncRoute, RouteDefinition} from './route_config_impl'; -export var RouteConfig = makeDecorator(RouteConfigAnnotation); +export var RouteConfig: (configs: List) => ClassDecorator = + makeDecorator(RouteConfigAnnotation); diff --git a/typing_spec/router_spec.dart b/typing_spec/router_spec.dart new file mode 100644 index 0000000000..e69de29bb2 diff --git a/typing_spec/router_spec.ts b/typing_spec/router_spec.ts new file mode 100644 index 0000000000..ea6ca0154a --- /dev/null +++ b/typing_spec/router_spec.ts @@ -0,0 +1,33 @@ +/// +/// + +import {Component, bootstrap, View} from 'angular2/angular2'; +import {RouteConfig, routerDirectives, routerInjectables} from 'angular2/router'; + +@Component({ + selector: 'my-app' +}) +@View({ + template: '

Hello

', +}) +class FooCmp { +} + + +@Component({ + selector: 'my-app' +}) +@View({ + template: '

Hello {{ name }}

', + directives: routerDirectives +}) +@RouteConfig([ + {path: '/home', component: FooCmp} +]) +class MyAppComponent { + name: string; + + constructor() { this.name = 'Alice'; } +} + +bootstrap(MyAppComponent, routerInjectables);