Skip to content
Closed

Upgrade #4766

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
62 changes: 55 additions & 7 deletions modules/upgrade/src/angular.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare namespace angular {
run(a: any);
}
interface ICompileService {
(element: Element, transclude?: Function): ILinkFn;
(element: Element | NodeList | string, transclude?: Function): ILinkFn;
}
interface ILinkFn {
(scope: IScope, cloneAttachFn?: Function, options?: ILinkFnOptions): void
Expand All @@ -17,7 +17,8 @@ declare namespace angular {
futureParentElement?: Node
}
interface IRootScopeService {
$new(): IScope;
$new(isolate?: boolean): IScope;
$id: string;
$watch(expr: any, fn?: (a1?: any, a2?: any) => void);
$apply(): any;
$apply(exp: string): any;
Expand All @@ -29,19 +30,53 @@ declare namespace angular {
interface IScope extends IRootScopeService {}
interface IAngularBootstrapConfig {}
interface IDirective {
require?: string;
compile?: IDirectiveCompileFn;
controller?: any;
controllerAs?: string;
bindToController?: boolean | Object;
link?: IDirectiveLinkFn | IDirectivePrePost;
name?: string;
priority?: number;
replace?: boolean;
require?: any;
restrict?: string;
scope?: {[key: string]: string};
link?: {pre?: Function, post?: Function};
scope?: any;
template?: any;
templateUrl?: any;
terminal?: boolean;
transclude?: any;
}
interface IDirectiveCompileFn {
(templateElement: IAugmentedJQuery, templateAttributes: IAttributes,
transclude: ITranscludeFunction): IDirectivePrePost;
}
interface IDirectivePrePost {
pre?: IDirectiveLinkFn;
post?: IDirectiveLinkFn;
}
interface IDirectiveLinkFn {
(scope: IScope, instanceElement: IAugmentedJQuery, instanceAttributes: IAttributes,
controller: any, transclude: ITranscludeFunction): void;
}
interface IAttributes {
$observe(attr: string, fn: (v: string) => void);
}
interface ITranscludeFunction {}
interface ITranscludeFunction {
// If the scope is provided, then the cloneAttachFn must be as well.
(scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;
// If one argument is provided, then it's assumed to be the cloneAttachFn.
(cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
}
interface ICloneAttachFunction {
// Let's hint but not force cloneAttachFn's signature
(clonedElement?: IAugmentedJQuery, scope?: IScope): any;
}
interface IAugmentedJQuery {
bind(name: string, fn: () => void);
data(name: string, value?: any);
inheritedData(name: string, value?: any);
contents(): IAugmentedJQuery;
parent(): IAugmentedJQuery;
length: number;
[index: number]: Node;
}
Expand All @@ -52,7 +87,20 @@ declare namespace angular {
assign(context: any, value: any): any;
}
function element(e: Element): IAugmentedJQuery;
function bootstrap(e: Element, modules: IModule[], config: IAngularBootstrapConfig);
function bootstrap(e: Element, modules: string[], config: IAngularBootstrapConfig);
interface IHttpBackendService {
(method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number,
withCredentials?: boolean): void;
}
interface ICacheObject {
put<T>(key: string, value?: T): T;
get(key: string): any;
}
interface ITemplateCacheService extends ICacheObject {}
interface IControllerService {
(controllerConstructor: Function, locals?: any, later?: any, ident?: any): any;
(controllerName: string, locals?: any): any;
}

namespace auto {
interface IInjectorService {
Expand Down
4 changes: 3 additions & 1 deletion modules/upgrade/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export const NG2_INJECTOR = 'ng2.Injector';
export const NG2_PROTO_VIEW_REF_MAP = 'ng2.ProtoViewRefMap';
export const NG2_ZONE = 'ng2.NgZone';

export const NG1_REQUIRE_INJECTOR_REF = '$' + NG2_INJECTOR + 'Controller';
export const NG1_CONTROLLER = '$controller';
export const NG1_SCOPE = '$scope';
export const NG1_ROOT_SCOPE = '$rootScope';
export const NG1_COMPILE = '$compile';
export const NG1_HTTP_BACKEND = '$httpBackend';
export const NG1_INJECTOR = '$injector';
export const NG1_PARSE = '$parse';
export const NG1_TEMPLATE_CACHE = '$templateCache';
export const REQUIRE_INJECTOR = '^' + NG2_INJECTOR;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const INITIAL_VALUE = {
__UNINITIALIZED__: true
};

export class Ng2ComponentFacade {
export class DowngradeNg2ComponentAdapter {
component: any = null;
inputChangeCount: number = 0;
inputChanges: {[key: string]: SimpleChange} = null;
Expand Down Expand Up @@ -101,7 +101,7 @@ export class Ng2ComponentFacade {
this.component.onChanges(inputChanges);
});
}
this.componentScope.$watch(() => this.changeDetector.detectChanges());
this.componentScope.$watch(() => this.changeDetector && this.changeDetector.detectChanges());
}

projectContent() {
Expand Down
174 changes: 0 additions & 174 deletions modules/upgrade/src/ng1_facade.ts

This file was deleted.

Loading