Peter Bacon Darwin d6791ff0e0 feat(ngUpgrade): add support for AoT compiled upgrade applications
This commit introduces a new API to the ngUpgrade module, which is compatible
with AoT compilation. Primarily, it removes the dependency on reflection
over the Angular 2 metadata by introducing an API where this information
is explicitly defined, in the source code, in a way that is not lost through
AoT compilation.

This commit is a collaboration between @mhevery (who provided the original
design of the API); @gkalpak & @petebacondarwin (who implemented the
API and migrated the specs from the original ngUpgrade tests) and @alexeagle
(who provided input and review).

This commit is an starting point, there is still work to be done:

* add more documentation
* validate the API via internal projects
* align the ngUpgrade compilation of A1 directives closer to the real A1
  compiler
* add more unit tests
* consider support for async `templateUrl` A1 upgraded components

Closes #12239
2016-10-19 15:27:49 -07:00

45 lines
1.5 KiB
TypeScript

/** @experimental */
export declare function downgradeComponent(info: ComponentInfo): angular.IInjectable;
/** @experimental */
export declare function downgradeInjectable(token: any): (string | ((i: Injector) => any))[];
/** @stable */
export declare class UpgradeAdapter {
constructor(ng2AppModule: Type<any>, compilerOptions?: CompilerOptions);
bootstrap(element: Element, modules?: any[], config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef;
downgradeNg2Component(type: Type<any>): Function;
downgradeNg2Provider(token: any): Function;
upgradeNg1Component(name: string): Type<any>;
upgradeNg1Provider(name: string, options?: {
asToken: any;
}): void;
}
/** @stable */
export declare class UpgradeAdapterRef {
ng1Injector: angular.IInjectorService;
ng1RootScope: angular.IRootScopeService;
ng2Injector: Injector;
ng2ModuleRef: NgModuleRef<any>;
dispose(): void;
ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void): void;
}
/** @experimental */
export declare class UpgradeComponent implements OnInit, OnChanges, DoCheck {
constructor(name: string, elementRef: ElementRef, injector: Injector);
ngDoCheck(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
}
/** @experimental */
export declare class UpgradeModule {
$injector: angular.IInjectorService;
injector: Injector;
ngZone: NgZone;
constructor(injector: Injector, ngZone: NgZone);
bootstrap(element: Element, modules?: string[], config?: angular.IAngularBootstrapConfig): void;
}