chore: fix DDC errors / warnings

Closes #7195
This commit is contained in:
Misko Hevery
2016-02-19 11:49:31 -08:00
committed by Miško Hevery
parent ef9e40e82b
commit 14f0e9ada8
88 changed files with 527 additions and 468 deletions

View File

@ -128,7 +128,7 @@ function _createPlatform(providers?: Array<Type | Provider | any[]>): PlatformRe
}
function _runPlatformInitializers(injector: Injector): void {
let inits: Function[] = injector.getOptional(PLATFORM_INITIALIZER);
let inits: Function[] = <Function[]>injector.getOptional(PLATFORM_INITIALIZER);
if (isPresent(inits)) inits.forEach(init => init());
}
@ -150,7 +150,7 @@ export abstract class PlatformRef {
* Retrieve the platform {@link Injector}, which is the parent injector for
* every Angular application on the page and provides singleton providers.
*/
get injector(): Injector { return unimplemented(); };
get injector(): Injector { throw unimplemented(); };
/**
* Instantiate a new Angular application on the page.
@ -222,7 +222,7 @@ export class PlatformRef_ extends PlatformRef {
asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>,
additionalProviders?: Array<Type | Provider | any[]>): Promise<ApplicationRef> {
var zone = createNgZone();
var completer = PromiseWrapper.completer();
var completer = PromiseWrapper.completer<ApplicationRef>();
if (bindingFn === null) {
completer.resolve(this._initApp(zone, additionalProviders));
} else {
@ -342,12 +342,12 @@ export abstract class ApplicationRef {
/**
* Retrieve the application {@link Injector}.
*/
get injector(): Injector { return unimplemented(); };
get injector(): Injector { return <Injector>unimplemented(); };
/**
* Retrieve the application {@link NgZone}.
*/
get zone(): NgZone { return unimplemented(); };
get zone(): NgZone { return <NgZone>unimplemented(); };
/**
* Dispose of this application and all of its components.
@ -369,7 +369,7 @@ export abstract class ApplicationRef {
/**
* Get a list of component types registered to this application.
*/
get componentTypes(): Type[] { return unimplemented(); };
get componentTypes(): Type[] { return <Type[]>unimplemented(); };
}
export class ApplicationRef_ extends ApplicationRef {
@ -449,13 +449,13 @@ export class ApplicationRef_ extends ApplicationRef {
completer.reject(e, e.stack);
}
});
return completer.promise.then(_ => {
return completer.promise.then<ComponentRef>((ref: ComponentRef) => {
let c = this._injector.get(Console);
if (assertionsEnabled()) {
c.log(
"Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.");
}
return _;
return ref;
});
}

View File

@ -64,8 +64,9 @@ export class DynamicProtoChangeDetector implements ProtoChangeDetector {
export function createPropertyRecords(definition: ChangeDetectorDefinition): ProtoRecord[] {
var recordBuilder = new ProtoRecordBuilder();
ListWrapper.forEachWithIndex(definition.bindingRecords,
(b, index) => recordBuilder.add(b, definition.variableNames, index));
ListWrapper.forEachWithIndex(
definition.bindingRecords,
(b: BindingRecord, index: number) => recordBuilder.add(b, definition.variableNames, index));
return coalesce(recordBuilder.records);
}

View File

@ -91,19 +91,19 @@ export class DebugElement extends DebugNode {
}
queryAll(predicate: Predicate<DebugElement>): DebugElement[] {
var matches = [];
var matches: DebugElement[] = [];
_queryElementChildren(this, predicate, matches);
return matches;
}
queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[] {
var matches = [];
var matches: DebugNode[] = [];
_queryNodeChildren(this, predicate, matches);
return matches;
}
get children(): DebugElement[] {
var children = [];
var children: DebugElement[] = [];
this.childNodes.forEach((node) => {
if (node instanceof DebugElement) {
children.push(node);

View File

@ -73,7 +73,7 @@ export class DebugDomRenderer implements Renderer {
if (isPresent(debugNode)) {
var debugParent = debugNode.parent;
if (viewRootNodes.length > 0 && isPresent(debugParent)) {
var debugViewRootNodes = [];
var debugViewRootNodes: DebugNode[] = [];
viewRootNodes.forEach((rootNode) => debugViewRootNodes.push(getDebugNode(rootNode)));
debugParent.insertChildrenAfter(debugNode, debugViewRootNodes);
}

View File

@ -513,7 +513,7 @@ export class ProviderBuilder {
*/
export function resolveFactory(provider: Provider): ResolvedFactory {
var factoryFn: Function;
var resolvedDeps;
var resolvedDeps: Dependency[];
if (isPresent(provider.useClass)) {
var useClass = resolveForwardRef(provider.useClass);
factoryFn = reflector.factory(useClass);
@ -619,7 +619,7 @@ function _constructDependencies(factoryFunction: Function, dependencies: any[]):
}
function _dependenciesFor(typeOrFunc): Dependency[] {
var params = reflector.parameters(typeOrFunc);
var params: any[][] = reflector.parameters(typeOrFunc);
if (isBlank(params)) return [];
if (params.some(isBlank)) {
throw new NoAnnotationError(typeOrFunc, params);

View File

@ -115,8 +115,9 @@ export class AppView implements ChangeDispatcher {
this.disposables = disposables;
this.appElements = appElements;
var localsMap = new Map<string, any>();
StringMapWrapper.forEach(this.proto.templateVariableBindings,
(templateName, _) => { localsMap.set(templateName, null); });
StringMapWrapper.forEach(
this.proto.templateVariableBindings,
(templateName: string, _: string) => { localsMap.set(templateName, null); });
for (var i = 0; i < appElements.length; i++) {
var appEl = appElements[i];
var providerTokens = [];
@ -125,13 +126,14 @@ export class AppView implements ChangeDispatcher {
providerTokens.push(appEl.proto.protoInjector.getProviderAtIndex(j).key.token);
}
}
StringMapWrapper.forEach(appEl.proto.directiveVariableBindings, (directiveIndex, name) => {
if (isBlank(directiveIndex)) {
localsMap.set(name, appEl.nativeElement);
} else {
localsMap.set(name, appEl.getDirectiveAtIndex(directiveIndex));
}
});
StringMapWrapper.forEach(appEl.proto.directiveVariableBindings,
(directiveIndex: number, name: string) => {
if (isBlank(directiveIndex)) {
localsMap.set(name, appEl.nativeElement);
} else {
localsMap.set(name, appEl.getDirectiveAtIndex(directiveIndex));
}
});
this.renderer.setElementDebugInfo(
appEl.nativeElement, new RenderDebugInfo(appEl.getInjector(), appEl.getComponent(),
providerTokens, localsMap));

View File

@ -41,7 +41,7 @@ export abstract class ViewContainerRef {
* Anchor element that specifies the location of this container in the containing View.
* <!-- TODO: rename to anchorElement -->
*/
get element(): ElementRef { return unimplemented(); }
get element(): ElementRef { return <ElementRef>unimplemented(); }
/**
* Destroys all Views in this container.
@ -60,7 +60,7 @@ export abstract class ViewContainerRef {
/**
* Returns the number of Views currently attached to this container.
*/
get length(): number { return unimplemented(); };
get length(): number { return <number>unimplemented(); };
/**
* Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it

View File

@ -6,9 +6,9 @@ export abstract class ViewRef {
/**
* @internal
*/
get changeDetectorRef(): ChangeDetectorRef { return unimplemented(); };
get changeDetectorRef(): ChangeDetectorRef { return <ChangeDetectorRef>unimplemented(); };
get destroyed(): boolean { return unimplemented(); }
get destroyed(): boolean { return <boolean>unimplemented(); }
}
/**
@ -21,7 +21,7 @@ export abstract class ViewRef {
* {@link AppViewManager#createHostViewInContainer}, {@link ViewContainerRef#createHostView}.
*/
export abstract class HostViewRef extends ViewRef {
get rootNodes(): any[] { return unimplemented(); };
get rootNodes(): any[] { return <any[]>unimplemented(); };
}
/**
@ -88,7 +88,7 @@ export abstract class EmbeddedViewRef extends ViewRef {
*/
abstract hasLocal(variableName: string): boolean;
get rootNodes(): any[] { return unimplemented(); };
get rootNodes(): any[] { return <any[]>unimplemented(); };
}
export class ViewRef_ implements EmbeddedViewRef, HostViewRef {
@ -116,4 +116,4 @@ export class HostViewFactoryRef_ implements HostViewFactoryRef {
constructor(private _hostViewFactory: HostViewFactory) {}
get internalHostViewFactory(): HostViewFactory { return this._hostViewFactory; }
}
}

View File

@ -87,7 +87,7 @@ export class Reflector {
}
}
parameters(typeOrFunc: /*Type*/ any): any[] {
parameters(typeOrFunc: /*Type*/ any): any[][] {
if (this._injectableInfo.has(typeOrFunc)) {
var res = this._getReflectionInfo(typeOrFunc).parameters;
return isPresent(res) ? res : [];
@ -148,7 +148,7 @@ export class Reflector {
}
/** @internal */
_getReflectionInfo(typeOrFunc: any) {
_getReflectionInfo(typeOrFunc: any): ReflectionInfo {
if (isPresent(this._usedKeys)) {
this._usedKeys.add(typeOrFunc);
}