Skip to content

Commit 6fa4002

Browse files
committed
Merge branch 'transforms-flags' into transforms-transformer
2 parents cbb910a + 51dd27a commit 6fa4002

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/compiler/core.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace ts {
9696
* returns a falsey value, then returns false.
9797
* If no such value is found, the callback is applied to each element of array and `true` is returned.
9898
*/
99-
export function trueForAll<T>(array: T[], callback: (element: T, index: number) => boolean): boolean {
99+
export function every<T>(array: T[], callback: (element: T, index: number) => boolean): boolean {
100100
if (array) {
101101
for (let i = 0, len = array.length; i < len; i++) {
102102
if (!callback(array[i], i)) {
@@ -252,14 +252,14 @@ namespace ts {
252252
return ~low;
253253
}
254254

255-
export function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
256-
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
257-
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
255+
export function reduceLeft<T, U>(array: T[], f: (memo: U, value: T) => U, initial: U): U;
256+
export function reduceLeft<T>(array: T[], f: (memo: T, value: T) => T): T;
257+
export function reduceLeft<T>(array: T[], f: (memo: T, value: T) => T, initial?: T): T {
258258
if (array) {
259259
const count = array.length;
260260
if (count > 0) {
261261
let pos = 0;
262-
let result: T | U;
262+
let result: T;
263263
if (arguments.length <= 2) {
264264
result = array[pos];
265265
pos++;
@@ -268,22 +268,22 @@ namespace ts {
268268
result = initial;
269269
}
270270
while (pos < count) {
271-
result = f(<U>result, array[pos]);
271+
result = f(result, array[pos]);
272272
pos++;
273273
}
274-
return <U>result;
274+
return result;
275275
}
276276
}
277277
return initial;
278278
}
279279

280-
export function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
281-
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
282-
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
280+
export function reduceRight<T, U>(array: T[], f: (memo: U, value: T) => U, initial: U): U;
281+
export function reduceRight<T>(array: T[], f: (memo: T, value: T) => T): T;
282+
export function reduceRight<T>(array: T[], f: (memo: T, value: T) => T, initial?: T): T {
283283
if (array) {
284284
let pos = array.length - 1;
285285
if (pos >= 0) {
286-
let result: T | U;
286+
let result: T;
287287
if (arguments.length <= 2) {
288288
result = array[pos];
289289
pos--;
@@ -292,10 +292,10 @@ namespace ts {
292292
result = initial;
293293
}
294294
while (pos >= 0) {
295-
result = f(<U>result, array[pos]);
295+
result = f(result, array[pos]);
296296
pos--;
297297
}
298-
return <U>result;
298+
return result;
299299
}
300300
}
301301
return initial;

src/compiler/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,13 +2755,6 @@ namespace ts {
27552755
ES6 = 1 << 6,
27562756
ContainsES6 = 1 << 7,
27572757

2758-
// Assertions
2759-
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
2760-
AssertTypeScript = TypeScript | ContainsTypeScript,
2761-
AssertJsx = Jsx | ContainsJsx,
2762-
AssertES7 = ES7 | ContainsES7,
2763-
AssertES6 = ES6 | ContainsES6,
2764-
27652758
// Markers
27662759
// - Flags used to indicate that a subtree contains a specific transformation.
27672760
ContainsDecorators = 1 << 8,
@@ -2773,6 +2766,13 @@ namespace ts {
27732766
ContainsSpreadElementExpression = 1 << 14,
27742767
ContainsComputedPropertyName = 1 << 15,
27752768

2769+
// Assertions
2770+
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
2771+
AssertTypeScript = TypeScript | ContainsTypeScript,
2772+
AssertJsx = Jsx | ContainsJsx,
2773+
AssertES7 = ES7 | ContainsES7,
2774+
AssertES6 = ES6 | ContainsES6,
2775+
27762776
// Scope Exclusions
27772777
// - Bitmasks that exclude flags from propagating out of a specific context
27782778
// into the subtree flags of their container.

src/compiler/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ namespace ts {
755755
* @param nodes The NodeArray.
756756
*/
757757
function liftToBlock(nodes: NodeArray<Node>) {
758-
Debug.assert(trueForAll(nodes, isStatement), "Cannot lift nodes to a Block.");
758+
Debug.assert(every(nodes, isStatement), "Cannot lift nodes to a Block.");
759759
return createBlock(<NodeArray<Statement>>nodes);
760760
}
761761

0 commit comments

Comments
 (0)