fix(types): parametrize QueryList.

This commit is contained in:
Rado Kirov 2015-06-03 15:39:20 -07:00
parent 20e874d3c6
commit 552985e305
8 changed files with 17 additions and 19 deletions

View File

@ -1,6 +1,5 @@
library angular2.src.core.compiler.base_query_list;
import 'package:angular2/src/core/annotations_impl/annotations.dart';
import 'dart:collection';
/**
@ -10,8 +9,8 @@ import 'dart:collection';
* In the future this class will implement an Observable interface.
* For now it uses a plain list of observable callbacks.
*/
class BaseQueryList extends Object with IterableMixin<Directive> {
List<Directive> _results;
class BaseQueryList<T> extends Object with IterableMixin<T> {
List<T> _results;
List _callbacks;
bool _dirty;
@ -20,7 +19,7 @@ class BaseQueryList extends Object with IterableMixin<Directive> {
_callbacks = [],
_dirty = false;
Iterator<Directive> get iterator => _results.iterator;
Iterator<T> get iterator => _results.iterator;
reset(newList) {
_results = newList;

View File

@ -1,5 +1,4 @@
import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
/**
* Injectable Objects that contains a live list of child directives in the light Dom of a directive.
@ -10,8 +9,8 @@ import {Directive} from 'angular2/src/core/annotations_impl/annotations';
*
* @exportedAs angular2/view
*/
export class BaseQueryList {
_results: List<Directive>;
export class BaseQueryList<T> {
_results: List<T>;
_callbacks;
_dirty;

View File

@ -947,7 +947,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
}
private _createQueryRef(directive): void {
var queryList = new QueryList();
var queryList = new QueryList<any>();
if (isBlank(this._query0)) {
this._query0 = new QueryRef(directive, queryList, this);
} else if (isBlank(this._query1)) {
@ -1515,10 +1515,10 @@ class QueryError extends BaseException {
class QueryRef {
directive;
list: QueryList;
list: QueryList<any>;
originator: ElementInjector;
constructor(directive, list: QueryList, originator: ElementInjector) {
constructor(directive, list: QueryList<any>, originator: ElementInjector) {
this.directive = directive;
this.list = list;
this.originator = originator;

View File

@ -75,7 +75,7 @@ import {BaseQueryList} from './base_query_list';
*
* @exportedAs angular2/view
*/
export class QueryList extends BaseQueryList {
export class QueryList<T> extends BaseQueryList<T> {
/**
*/
onChange(callback) { return super.onChange(callback); }

View File

@ -157,8 +157,8 @@ class NeedsAttributeNoType {
@Injectable()
class NeedsQuery {
query: QueryList;
constructor(@Query(CountingDirective) query: QueryList) { this.query = query; }
query: QueryList<CountingDirective>;
constructor(@Query(CountingDirective) query: QueryList<CountingDirective>) { this.query = query; }
}
@Injectable()

View File

@ -1540,10 +1540,10 @@ class ToolbarViewContainer {
})
@Injectable()
class ToolbarComponent {
query: QueryList;
query: QueryList<ToolbarPart>;
ctxProp: string;
constructor(@Query(ToolbarPart) query: QueryList) {
constructor(@Query(ToolbarPart) query: QueryList<ToolbarPart>) {
this.ctxProp = 'hello world';
this.query = query;
}

View File

@ -98,8 +98,8 @@ class TextDirective {
@View({directives: [NgFor], template: '<div *ng-for="var dir of query">{{dir.text}}|</div>'})
@Injectable()
class NeedsQuery {
query: QueryList;
constructor(@Query(TextDirective) query: QueryList) { this.query = query; }
query: QueryList<TextDirective>;
constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
}
var _constructiontext = 0;

View File

@ -46,10 +46,10 @@ class App {
template: `{{frame.name}}(<span *ng-for="var lock of locks">{{lock.name}}</span>)`
})
class Door {
locks: QueryList;
locks: QueryList<Lock>;
frame: Frame;
constructor(@Query(forwardRef(() => Lock)) locks: QueryList,
constructor(@Query(forwardRef(() => Lock)) locks: QueryList<Lock>,
@Inject(forwardRef(() => Frame)) frame: Frame) {
this.frame = frame;
this.locks = locks;