Skip to content

Commit b986c54

Browse files
committed
chore: remove int in favor for number
Closes angular#3511
1 parent 8336881 commit b986c54

File tree

22 files changed

+95
-93
lines changed

22 files changed

+95
-93
lines changed

modules/angular2/globals.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/// <reference path="typings/zone/zone.d.ts"/>
66
declare var assert: any;
7-
declare type int = number;
87

98
interface List<T> extends Array<T> {}
109

modules/angular2/src/change_detection/codegen_name_util.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ export class CodegenNameUtil {
8383
return this._addFieldPrefix(_FIRST_PROTO_IN_CURRENT_BINDING);
8484
}
8585

86-
getLocalName(idx: int): string { return `l_${this._sanitizedNames[idx]}`; }
86+
getLocalName(idx: number): string { return `l_${this._sanitizedNames[idx]}`; }
8787

88-
getEventLocalName(eb: EventBinding, idx: int): string {
88+
getEventLocalName(eb: EventBinding, idx: number): string {
8989
return `l_${MapWrapper.get(this._sanitizedEventNames, eb)[idx]}`;
9090
}
9191

92-
getChangeName(idx: int): string { return `c_${this._sanitizedNames[idx]}`; }
92+
getChangeName(idx: number): string { return `c_${this._sanitizedNames[idx]}`; }
9393

9494
/**
9595
* Generate a statement initializing local variables used when detecting changes.
@@ -133,9 +133,9 @@ export class CodegenNameUtil {
133133

134134
getPreventDefaultAccesor(): string { return "preventDefault"; }
135135

136-
getFieldCount(): int { return this._sanitizedNames.length; }
136+
getFieldCount(): number { return this._sanitizedNames.length; }
137137

138-
getFieldName(idx: int): string { return this._addFieldPrefix(this._sanitizedNames[idx]); }
138+
getFieldName(idx: number): string { return this._addFieldPrefix(this._sanitizedNames[idx]); }
139139

140140
getAllFieldNames(): List<string> {
141141
var fieldList = [];
@@ -188,7 +188,7 @@ export class CodegenNameUtil {
188188
'\n');
189189
}
190190

191-
getPipeName(idx: int): string {
191+
getPipeName(idx: number): string {
192192
return this._addFieldPrefix(`${this._sanitizedNames[idx]}_pipe`);
193193
}
194194

modules/angular2/src/change_detection/differs/default_iterable_differ.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class DefaultIterableDifferFactory implements IterableDifferFactory {
2626

2727
export class DefaultIterableDiffer implements IterableDiffer {
2828
private _collection = null;
29-
private _length: int = null;
29+
private _length: number = null;
3030
// Keeps track of the used records at any point in time (during & across `_check()` calls)
3131
private _linkedRecords: _DuplicateMap = null;
3232
// Keeps track of the removed records at any point in time during `_check()` calls.
@@ -43,7 +43,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
4343

4444
get collection() { return this._collection; }
4545

46-
get length(): int { return this._length; }
46+
get length(): number { return this._length; }
4747

4848
forEachItem(fn: Function) {
4949
var record: CollectionChangeRecord;
@@ -101,7 +101,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
101101

102102
var record: CollectionChangeRecord = this._itHead;
103103
var mayBeDirty: boolean = false;
104-
var index: int;
104+
var index: number;
105105
var item;
106106

107107
if (isArray(collection)) {
@@ -185,7 +185,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
185185
* - `item` is the current item in the collection
186186
* - `index` is the position of the item in the collection
187187
*/
188-
_mismatch(record: CollectionChangeRecord, item, index: int): CollectionChangeRecord {
188+
_mismatch(record: CollectionChangeRecord, item, index: number): CollectionChangeRecord {
189189
// The previous record after which we will append the current one.
190190
var previousRecord: CollectionChangeRecord;
191191

@@ -241,7 +241,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
241241
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
242242
* at the end.
243243
*/
244-
_verifyReinsertion(record: CollectionChangeRecord, item, index: int): CollectionChangeRecord {
244+
_verifyReinsertion(record: CollectionChangeRecord, item, index: number): CollectionChangeRecord {
245245
var reinsertRecord: CollectionChangeRecord =
246246
this._unlinkedRecords === null ? null : this._unlinkedRecords.get(item);
247247
if (reinsertRecord !== null) {
@@ -284,7 +284,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
284284
}
285285

286286
_reinsertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
287-
index: int): CollectionChangeRecord {
287+
index: number): CollectionChangeRecord {
288288
if (this._unlinkedRecords !== null) {
289289
this._unlinkedRecords.remove(record);
290290
}
@@ -308,15 +308,15 @@ export class DefaultIterableDiffer implements IterableDiffer {
308308
}
309309

310310
_moveAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
311-
index: int): CollectionChangeRecord {
311+
index: number): CollectionChangeRecord {
312312
this._unlink(record);
313313
this._insertAfter(record, prevRecord, index);
314314
this._addToMoves(record, index);
315315
return record;
316316
}
317317

318318
_addAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
319-
index: int): CollectionChangeRecord {
319+
index: number): CollectionChangeRecord {
320320
this._insertAfter(record, prevRecord, index);
321321

322322
if (this._additionsTail === null) {
@@ -333,7 +333,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
333333
}
334334

335335
_insertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
336-
index: int): CollectionChangeRecord {
336+
index: number): CollectionChangeRecord {
337337
// todo(vicb)
338338
// assert(record != prevRecord);
339339
// assert(record._next === null);
@@ -395,7 +395,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
395395
return record;
396396
}
397397

398-
_addToMoves(record: CollectionChangeRecord, toIndex: int): CollectionChangeRecord {
398+
_addToMoves(record: CollectionChangeRecord, toIndex: number): CollectionChangeRecord {
399399
// todo(vicb)
400400
// assert(record._nextMoved === null);
401401

@@ -473,8 +473,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
473473
}
474474

475475
export class CollectionChangeRecord {
476-
currentIndex: int = null;
477-
previousIndex: int = null;
476+
currentIndex: number = null;
477+
previousIndex: number = null;
478478

479479
_nextPrevious: CollectionChangeRecord = null;
480480
_prev: CollectionChangeRecord = null;
@@ -524,7 +524,7 @@ class _DuplicateItemRecordList {
524524

525525
// Returns a CollectionChangeRecord having CollectionChangeRecord.item == item and
526526
// CollectionChangeRecord.currentIndex >= afterIndex
527-
get(item: any, afterIndex: int): CollectionChangeRecord {
527+
get(item: any, afterIndex: number): CollectionChangeRecord {
528528
var record: CollectionChangeRecord;
529529
for (record = this._head; record !== null; record = record._nextDup) {
530530
if ((afterIndex === null || afterIndex < record.currentIndex) &&
@@ -588,7 +588,7 @@ class _DuplicateMap {
588588
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
589589
* have any more `a`s needs to return the last `a` not the first or second.
590590
*/
591-
get(value: any, afterIndex: int = null): CollectionChangeRecord {
591+
get(value: any, afterIndex: number = null): CollectionChangeRecord {
592592
var key = getMapKey(value);
593593

594594
var recordList = this.map.get(key);

modules/angular2/src/change_detection/parser/parser.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,24 @@ export class Parser {
122122
}
123123

124124
export class _ParseAST {
125-
index: int = 0;
125+
index: number = 0;
126126
constructor(public input: string, public location: any, public tokens: List<any>,
127127
public reflector: Reflector, public parseAction: boolean) {}
128128

129-
peek(offset: int): Token {
129+
peek(offset: number): Token {
130130
var i = this.index + offset;
131131
return i < this.tokens.length ? this.tokens[i] : EOF;
132132
}
133133

134134
get next(): Token { return this.peek(0); }
135135

136-
get inputIndex(): int {
136+
get inputIndex(): number {
137137
return (this.index < this.tokens.length) ? this.next.index : this.input.length;
138138
}
139139

140140
advance() { this.index++; }
141141

142-
optionalCharacter(code: int): boolean {
142+
optionalCharacter(code: number): boolean {
143143
if (this.next.isCharacter(code)) {
144144
this.advance();
145145
return true;
@@ -159,7 +159,7 @@ export class _ParseAST {
159159

160160
peekKeywordVar(): boolean { return this.next.isKeywordVar() || this.next.isOperator('#'); }
161161

162-
expectCharacter(code: int) {
162+
expectCharacter(code: number) {
163163
if (this.optionalCharacter(code)) return;
164164
this.error(`Missing expected ${StringWrapper.fromCharCode(code)}`);
165165
}
@@ -453,7 +453,7 @@ export class _ParseAST {
453453
throw new BaseException("Fell through all cases in parsePrimary");
454454
}
455455

456-
parseExpressionList(terminator: int): List<any> {
456+
parseExpressionList(terminator: number): List<any> {
457457
var result = [];
458458
if (!this.next.isCharacter(terminator)) {
459459
do {
@@ -606,7 +606,7 @@ export class _ParseAST {
606606
return bindings;
607607
}
608608

609-
error(message: string, index: int = null) {
609+
error(message: string, index: number = null) {
610610
if (isBlank(index)) index = this.index;
611611

612612
var location = (index < this.tokens.length) ? `at column ${this.tokens[index].index + 1} in` :

modules/angular2/src/core/compiler/element_binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ElementBinder {
77
// updated later, so we are able to resolve cycles
88
nestedProtoView: viewModule.AppProtoView = null;
99

10-
constructor(public index: int, public parent: ElementBinder, public distanceToParent: int,
10+
constructor(public index: number, public parent: ElementBinder, public distanceToParent: number,
1111
public protoElementInjector: eiModule.ProtoElementInjector,
1212
public componentDirective: DirectiveBinding) {
1313
if (isBlank(index)) {

modules/angular2/src/core/compiler/element_injector.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,9 @@ export class ProtoElementInjector {
378378

379379

380380

381-
constructor(public parent: ProtoElementInjector, public index: int, bwv: BindingWithVisibility[],
382-
public distanceToParent: number, public _firstBindingIsComponent: boolean,
381+
constructor(public parent: ProtoElementInjector, public index: number,
382+
bwv: BindingWithVisibility[], public distanceToParent: number,
383+
public _firstBindingIsComponent: boolean,
383384
public directiveVariableBindings: Map<string, number>) {
384385
var length = bwv.length;
385386

modules/angular2/src/core/compiler/view.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
162162
*
163163
* @param {string} eventName
164164
* @param {*} eventObj
165-
* @param {int} boundElementIndex
165+
* @param {number} boundElementIndex
166166
*/
167-
triggerEventHandlers(eventName: string, eventObj: Event, boundElementIndex: int): void {
167+
triggerEventHandlers(eventName: string, eventObj: Event, boundElementIndex: number): void {
168168
var locals = new Map();
169169
locals.set('$event', eventObj);
170170
this.dispatchEvent(boundElementIndex, eventName, locals);
@@ -328,7 +328,7 @@ export class AppProtoView {
328328
}
329329
}
330330

331-
bindElement(parent: ElementBinder, distanceToParent: int,
331+
bindElement(parent: ElementBinder, distanceToParent: number,
332332
protoElementInjector: ProtoElementInjector,
333333
componentDirective: DirectiveBinding = null): ElementBinder {
334334
var elBinder = new ElementBinder(this.elementBinders.length, parent, distanceToParent,

modules/angular2/src/facade/async.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ export class PromiseWrapper {
5858
}
5959

6060
export class TimerWrapper {
61-
static setTimeout(fn: Function, millis: int): int { return global.setTimeout(fn, millis); }
62-
static clearTimeout(id: int): void { global.clearTimeout(id); }
61+
static setTimeout(fn: Function, millis: number): number { return global.setTimeout(fn, millis); }
62+
static clearTimeout(id: number): void { global.clearTimeout(id); }
6363

64-
static setInterval(fn: Function, millis: int): int { return global.setInterval(fn, millis); }
65-
static clearInterval(id: int): void { global.clearInterval(id); }
64+
static setInterval(fn: Function, millis: number): number {
65+
return global.setInterval(fn, millis);
66+
}
67+
static clearInterval(id: number): void { global.clearInterval(id); }
6668
}
6769

6870
export class ObservableWrapper {

modules/angular2/src/facade/intl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ export class NumberFormatter {
5151
static format(number: number, locale: string, style: NumberFormatStyle,
5252
{minimumIntegerDigits = 1, minimumFractionDigits = 0, maximumFractionDigits = 3,
5353
currency, currencyAsSymbol = false}: {
54-
minimumIntegerDigits?: int,
55-
minimumFractionDigits?: int,
56-
maximumFractionDigits?: int,
54+
minimumIntegerDigits?: number,
55+
minimumFractionDigits?: number,
56+
maximumFractionDigits?: number,
5757
currency?: string,
5858
currencyAsSymbol?: boolean
5959
} = {}): string {
@@ -71,10 +71,10 @@ export class NumberFormatter {
7171
}
7272
}
7373

74-
function digitCondition(len: int): string {
74+
function digitCondition(len: number): string {
7575
return len == 2 ? '2-digit' : 'numeric';
7676
}
77-
function nameCondition(len: int): string {
77+
function nameCondition(len: number): string {
7878
return len < 4 ? 'short' : 'long';
7979
}
8080
function extractComponents(pattern: string): Intl.DateTimeFormatOptions {

modules/angular2/src/facade/lang.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int serializeEnum(val) {
5050
* val should be the indexed value of the enum (sa returned from @Link{serializeEnum})
5151
* values should be a map from indexes to values for the enum that you want to deserialize.
5252
*/
53-
dynamic deserializeEnum(int val, Map<int, dynamic> values) {
53+
dynamic deserializeEnum(num val, Map<num, dynamic> values) {
5454
return values[val];
5555
}
5656

0 commit comments

Comments
 (0)