fix(ddc): type fixes necessary to bring DDC severe count to 0

This commit is contained in:
Yegor Jbanov 2016-01-21 18:13:58 -08:00 committed by Yegor
parent 9c96b8affc
commit 4282297c24
13 changed files with 82 additions and 59 deletions

View File

@ -21,7 +21,7 @@ class ObservableListDiff extends DefaultIterableDiffer {
}
}
dynamic diff(ObservableList collection) {
DefaultIterableDiffer diff(ObservableList collection) {
if (collection is! ObservableList) {
throw "Cannot change the type of a collection";
}

View File

@ -513,5 +513,5 @@ export class ApplicationRef_ extends ApplicationRef {
this._platform._applicationDisposed(this);
}
get componentTypes(): any[] { return this._rootComponentTypes; }
get componentTypes(): Type[] { return this._rootComponentTypes; }
}

View File

@ -22,7 +22,7 @@ import {IterableDiffer, IterableDifferFactory} from '../differs/iterable_differs
@CONST()
export class DefaultIterableDifferFactory implements IterableDifferFactory {
supports(obj: Object): boolean { return isListLikeIterable(obj); }
create(cdRef: ChangeDetectorRef): any { return new DefaultIterableDiffer(); }
create(cdRef: ChangeDetectorRef): DefaultIterableDiffer { return new DefaultIterableDiffer(); }
}
export class DefaultIterableDiffer implements IterableDiffer {

View File

@ -9,7 +9,7 @@ import {Provider, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2
* respond to changes in an iterable by effecting equivalent changes in the DOM.
*/
export interface IterableDiffer {
diff(object: Object): any;
diff(object: any): any;
onDestroy();
}
@ -17,7 +17,7 @@ export interface IterableDiffer {
* Provides a factory for {@link IterableDiffer}.
*/
export interface IterableDifferFactory {
supports(objects: Object): boolean;
supports(objects: any): boolean;
create(cdRef: ChangeDetectorRef): IterableDiffer;
}
@ -74,7 +74,7 @@ export class IterableDiffers {
});
}
find(iterable: Object): IterableDifferFactory {
find(iterable: any): IterableDifferFactory {
var factory = this.factories.find(f => f.supports(iterable));
if (isPresent(factory)) {
return factory;

View File

@ -8,7 +8,7 @@ import {Provider, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2
* A differ that tracks changes made to an object over time.
*/
export interface KeyValueDiffer {
diff(object: Object);
diff(object: any);
onDestroy();
}
@ -16,7 +16,7 @@ export interface KeyValueDiffer {
* Provides a factory for {@link KeyValueDiffer}.
*/
export interface KeyValueDifferFactory {
supports(objects: Object): boolean;
supports(objects: any): boolean;
create(cdRef: ChangeDetectorRef): KeyValueDiffer;
}

View File

@ -143,7 +143,7 @@ export class ProtoInjectorInlineStrategy implements ProtoInjectorStrategy {
}
}
getProviderAtIndex(index: number): any {
getProviderAtIndex(index: number): ResolvedProvider {
if (index == 0) return this.provider0;
if (index == 1) return this.provider1;
if (index == 2) return this.provider2;
@ -181,7 +181,7 @@ export class ProtoInjectorDynamicStrategy implements ProtoInjectorStrategy {
}
}
getProviderAtIndex(index: number): any {
getProviderAtIndex(index: number): ResolvedProvider {
if (index < 0 || index >= this.providers.length) {
throw new OutOfBoundsError(index);
}
@ -210,7 +210,9 @@ export class ProtoInjector {
new ProtoInjectorInlineStrategy(this, bwv);
}
getProviderAtIndex(index: number): any { return this._strategy.getProviderAtIndex(index); }
getProviderAtIndex(index: number): ResolvedProvider {
return this._strategy.getProviderAtIndex(index);
}
}

View File

@ -250,7 +250,7 @@ export class AppView implements ChangeDispatcher {
return this.appElements[directive.elementIndex].getDirectiveAtIndex(directive.directiveIndex);
}
getDetectorFor(directive: DirectiveIndex): any {
getDetectorFor(directive: DirectiveIndex): ChangeDetector {
var componentView = this.appElements[directive.elementIndex].componentView;
return isPresent(componentView) ? componentView.changeDetector : null;
}

View File

@ -133,13 +133,13 @@ export class ViewContainerRef_ extends ViewContainerRef {
// TODO(rado): profile and decide whether bounds checks should be added
// to the methods below.
createEmbeddedView(templateRef: TemplateRef_, index: number = -1): EmbeddedViewRef {
createEmbeddedView(templateRef: TemplateRef, index: number = -1): EmbeddedViewRef {
if (index == -1) index = this.length;
var vm = this._element.parentView.viewManager;
return vm.createEmbeddedViewInContainer(this._element.ref, index, templateRef);
}
createHostView(hostViewFactoryRef: HostViewFactoryRef_, index: number = -1,
createHostView(hostViewFactoryRef: HostViewFactoryRef, index: number = -1,
dynamicallyCreatedProviders: ResolvedProvider[] = null,
projectableNodes: any[][] = null): HostViewRef {
if (index == -1) index = this.length;
@ -149,14 +149,14 @@ export class ViewContainerRef_ extends ViewContainerRef {
}
// TODO(i): refactor insert+remove into move
insert(viewRef: ViewRef_, index: number = -1): EmbeddedViewRef {
insert(viewRef: ViewRef, index: number = -1): EmbeddedViewRef {
if (index == -1) index = this.length;
var vm = this._element.parentView.viewManager;
return vm.attachViewInContainer(this._element.ref, index, viewRef);
}
indexOf(viewRef: ViewRef_): number {
return ListWrapper.indexOf(this._element.nestedViews, viewRef.internalView);
indexOf(viewRef: ViewRef): number {
return ListWrapper.indexOf(this._element.nestedViews, (<ViewRef_>viewRef).internalView);
}
// TODO(i): rename to destroy

View File

@ -17,6 +17,7 @@ import {
HostViewFactoryRef_,
EmbeddedViewRef,
HostViewRef,
ViewRef,
ViewRef_
} from './view_ref';
import {ViewContainerRef} from './view_container_ref';
@ -189,20 +190,20 @@ export class AppViewManager_ extends AppViewManager {
super();
}
getViewContainer(location: ElementRef_): ViewContainerRef {
return location.internalElement.getViewContainerRef();
getViewContainer(location: ElementRef): ViewContainerRef {
return (<ElementRef_>location).internalElement.getViewContainerRef();
}
getHostElement(hostViewRef: ViewRef_): ElementRef {
var hostView = hostViewRef.internalView;
getHostElement(hostViewRef: ViewRef): ElementRef {
var hostView = (<ViewRef_>hostViewRef).internalView;
if (hostView.proto.type !== ViewType.HOST) {
throw new BaseException('This operation is only allowed on host views');
}
return hostView.appElements[0].ref;
}
getNamedElementInComponentView(hostLocation: ElementRef_, variableName: string): ElementRef {
var appEl = hostLocation.internalElement;
getNamedElementInComponentView(hostLocation: ElementRef, variableName: string): ElementRef {
var appEl = (<ElementRef_>hostLocation).internalElement;
var componentView = appEl.componentView;
if (isBlank(componentView)) {
throw new BaseException(`There is no component directive at element ${hostLocation}`);
@ -216,17 +217,17 @@ export class AppViewManager_ extends AppViewManager {
throw new BaseException(`Could not find variable ${variableName}`);
}
getComponent(hostLocation: ElementRef_): any {
return hostLocation.internalElement.getComponent();
getComponent(hostLocation: ElementRef): any {
return (<ElementRef_>hostLocation).internalElement.getComponent();
}
/** @internal */
_createRootHostViewScope: WtfScopeFn = wtfCreateScope('AppViewManager#createRootHostView()');
createRootHostView(hostViewFactoryRef: HostViewFactoryRef_, overrideSelector: string,
createRootHostView(hostViewFactoryRef: HostViewFactoryRef, overrideSelector: string,
injector: Injector, projectableNodes: any[][] = null): HostViewRef {
var s = this._createRootHostViewScope();
var hostViewFactory = hostViewFactoryRef.internalHostViewFactory;
var hostViewFactory = (<HostViewFactoryRef_>hostViewFactoryRef).internalHostViewFactory;
var selector = isPresent(overrideSelector) ? overrideSelector : hostViewFactory.selector;
var view = hostViewFactory.viewFactory(this._renderer, this, null, projectableNodes, selector,
null, injector);
@ -236,9 +237,9 @@ export class AppViewManager_ extends AppViewManager {
/** @internal */
_destroyRootHostViewScope: WtfScopeFn = wtfCreateScope('AppViewManager#destroyRootHostView()');
destroyRootHostView(hostViewRef: ViewRef_) {
destroyRootHostView(hostViewRef: ViewRef) {
var s = this._destroyRootHostViewScope();
var hostView = hostViewRef.internalView;
var hostView = (<ViewRef_>hostViewRef).internalView;
hostView.renderer.detachView(flattenNestedViewRenderNodes(hostView.rootNodesOrAppElements));
hostView.destroy();
wtfLeave(s);
@ -248,14 +249,14 @@ export class AppViewManager_ extends AppViewManager {
_createEmbeddedViewInContainerScope: WtfScopeFn =
wtfCreateScope('AppViewManager#createEmbeddedViewInContainer()');
createEmbeddedViewInContainer(viewContainerLocation: ElementRef_, index: number,
templateRef: TemplateRef_): EmbeddedViewRef {
createEmbeddedViewInContainer(viewContainerLocation: ElementRef, index: number,
templateRef: TemplateRef): EmbeddedViewRef {
var s = this._createEmbeddedViewInContainerScope();
var contextEl = templateRef.elementRef.internalElement;
var contextEl = (<TemplateRef_>templateRef).elementRef.internalElement;
var view: AppView =
contextEl.embeddedViewFactory(contextEl.parentView.renderer, this, contextEl,
contextEl.parentView.projectableNodes, null, null, null);
this._attachViewToContainer(view, viewContainerLocation.internalElement, index);
this._attachViewToContainer(view, (<ElementRef_>viewContainerLocation).internalElement, index);
return wtfLeave(s, view.ref);
}
@ -263,27 +264,29 @@ export class AppViewManager_ extends AppViewManager {
_createHostViewInContainerScope: WtfScopeFn =
wtfCreateScope('AppViewManager#createHostViewInContainer()');
createHostViewInContainer(viewContainerLocation: ElementRef_, index: number,
hostViewFactoryRef: HostViewFactoryRef_,
createHostViewInContainer(viewContainerLocation: ElementRef, index: number,
hostViewFactoryRef: HostViewFactoryRef,
dynamicallyCreatedProviders: ResolvedProvider[],
projectableNodes: any[][]): HostViewRef {
var s = this._createHostViewInContainerScope();
// TODO(tbosch): This should be specifiable via an additional argument!
var contextEl = viewContainerLocation.internalElement;
var hostViewFactory = hostViewFactoryRef.internalHostViewFactory;
var viewContainerLocation_ = <ElementRef_>viewContainerLocation;
var contextEl = viewContainerLocation_.internalElement;
var hostViewFactory = (<HostViewFactoryRef_>hostViewFactoryRef).internalHostViewFactory;
var view = hostViewFactory.viewFactory(
contextEl.parentView.renderer, contextEl.parentView.viewManager, contextEl,
projectableNodes, null, dynamicallyCreatedProviders, null);
this._attachViewToContainer(view, viewContainerLocation.internalElement, index);
this._attachViewToContainer(view, viewContainerLocation_.internalElement, index);
return wtfLeave(s, view.ref);
}
/** @internal */
_destroyViewInContainerScope = wtfCreateScope('AppViewMananger#destroyViewInContainer()');
destroyViewInContainer(viewContainerLocation: ElementRef_, index: number) {
destroyViewInContainer(viewContainerLocation: ElementRef, index: number) {
var s = this._destroyViewInContainerScope();
var view = this._detachViewInContainer(viewContainerLocation.internalElement, index);
var view =
this._detachViewInContainer((<ElementRef_>viewContainerLocation).internalElement, index);
view.destroy();
wtfLeave(s);
}
@ -292,20 +295,23 @@ export class AppViewManager_ extends AppViewManager {
_attachViewInContainerScope = wtfCreateScope('AppViewMananger#attachViewInContainer()');
// TODO(i): refactor detachViewInContainer+attachViewInContainer to moveViewInContainer
attachViewInContainer(viewContainerLocation: ElementRef_, index: number,
viewRef: ViewRef_): EmbeddedViewRef {
attachViewInContainer(viewContainerLocation: ElementRef, index: number,
viewRef: ViewRef): EmbeddedViewRef {
var viewRef_ = <ViewRef_>viewRef;
var s = this._attachViewInContainerScope();
this._attachViewToContainer(viewRef.internalView, viewContainerLocation.internalElement, index);
return wtfLeave(s, viewRef);
this._attachViewToContainer(viewRef_.internalView,
(<ElementRef_>viewContainerLocation).internalElement, index);
return wtfLeave(s, viewRef_);
}
/** @internal */
_detachViewInContainerScope = wtfCreateScope('AppViewMananger#detachViewInContainer()');
// TODO(i): refactor detachViewInContainer+attachViewInContainer to moveViewInContainer
detachViewInContainer(viewContainerLocation: ElementRef_, index: number): EmbeddedViewRef {
detachViewInContainer(viewContainerLocation: ElementRef, index: number): EmbeddedViewRef {
var s = this._detachViewInContainerScope();
var view = this._detachViewInContainer(viewContainerLocation.internalElement, index);
var view =
this._detachViewInContainer((<ElementRef_>viewContainerLocation).internalElement, index);
return wtfLeave(s, view.ref);
}

View File

@ -23,7 +23,7 @@ class NoReflectionCapabilities implements PlatformReflectionCapabilities {
}
@override
List parameters(dynamic type) {
List<List> parameters(dynamic type) {
throw "Cannot find reflection information on ${stringify(type)}";
}
@ -33,7 +33,7 @@ class NoReflectionCapabilities implements PlatformReflectionCapabilities {
}
@override
Map propMetadata(dynamic type) {
Map<String, List> propMetadata(dynamic type) {
throw "Cannot find reflection information on ${stringify(type)}";
}

View File

@ -73,16 +73,16 @@ class ObservableWrapper {
}
class EventEmitter<T> extends Stream<T> {
StreamController<dynamic> _controller;
StreamController<T> _controller;
/// Creates an instance of [EventEmitter], which depending on [isAsync],
/// delivers events synchronously or asynchronously.
EventEmitter([bool isAsync = true]) {
_controller = new StreamController.broadcast(sync: !isAsync);
_controller = new StreamController<T>.broadcast(sync: !isAsync);
}
StreamSubscription listen(void onData(dynamic line),
{void onError(Error error), void onDone(), bool cancelOnError}) {
StreamSubscription<T> listen(void onData(T event),
{Function onError, void onDone(), bool cancelOnError}) {
return _controller.stream.listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
@ -106,14 +106,14 @@ class EventEmitter<T> extends Stream<T> {
//todo(robwormald): maybe fix in ts2dart?
class Subject<T> extends Stream<T> {
StreamController<dynamic> _controller;
StreamController<T> _controller;
Subject([bool isAsync = true]) {
_controller = new StreamController.broadcast(sync: !isAsync);
_controller = new StreamController<T>.broadcast(sync: !isAsync);
}
StreamSubscription listen(void onData(dynamic line),
{void onError(Error error), void onDone(), bool cancelOnError}) {
StreamSubscription<T> listen(void onData(T data),
{Function onError, void onDone(), bool cancelOnError}) {
return _controller.stream.listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}

View File

@ -27,7 +27,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
return isPresent(KeyEventsPlugin.parseEventName(eventName));
}
addEventListener(element: HTMLElement, eventName: string, handler: (Event: any) => any) {
addEventListener(element: HTMLElement, eventName: string, handler: Function) {
var parsedEvent = KeyEventsPlugin.parseEventName(eventName);
var outsideHandler = KeyEventsPlugin.eventCallback(
@ -90,8 +90,8 @@ export class KeyEventsPlugin extends EventManagerPlugin {
return fullKey;
}
static eventCallback(element: HTMLElement, fullKey: any, handler: (e: Event) => any,
zone: NgZone): (event: KeyboardEvent) => void {
static eventCallback(element: HTMLElement, fullKey: any, handler: Function,
zone: NgZone): Function {
return (event) => {
if (StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
zone.run(() => handler(event));

View File

@ -60,3 +60,18 @@ then
else
echo "Warning count ok"
fi
function countWarnings {
local GREP_PATTERN=$1
local COUNT=`cat $LOG_FILE | grep -E '$GREP_PATTERN' | wc -l | sed -e 's/^[[:space:]]*//'`
echo $COUNT
}
SEVERE_ANGULAR_COUNT=$(countWarnings '^severe.*package:angular2')
if [[ "$SEVERE_ANGULAR_COUNT" -gt "0" ]]
then
echo "Found severe errors in angular2 package"
exit 1
fi
echo 'Dart DDC build finished'