From af24b166326468e37fecf269db0f3c6aeca020b0 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 9 Feb 2016 11:01:49 -0800 Subject: [PATCH 1/2] PR Feedback --- src/compiler/core.ts | 26 +++++++++++++------------- src/compiler/visitor.ts | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 14d49604f67..c7f05f4cf50 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -96,7 +96,7 @@ namespace ts { * returns a falsey value, then returns false. * If no such value is found, the callback is applied to each element of array and `true` is returned. */ - export function trueForAll(array: T[], callback: (element: T, index: number) => boolean): boolean { + export function every(array: T[], callback: (element: T, index: number) => boolean): boolean { if (array) { for (let i = 0, len = array.length; i < len; i++) { if (!callback(array[i], i)) { @@ -252,14 +252,14 @@ namespace ts { return ~low; } - export function reduceLeft(array: T[], f: (a: T, x: T) => T): T; - export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; - export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial?: U): U { + export function reduceLeft(array: T[], f: (memo: U, value: T) => U, initial: U): U; + export function reduceLeft(array: T[], f: (memo: T, value: T) => T): T; + export function reduceLeft(array: T[], f: (memo: T, value: T) => T, initial?: T): T { if (array) { const count = array.length; if (count > 0) { let pos = 0; - let result: T | U; + let result: T; if (arguments.length <= 2) { result = array[pos]; pos++; @@ -268,22 +268,22 @@ namespace ts { result = initial; } while (pos < count) { - result = f(result, array[pos]); + result = f(result, array[pos]); pos++; } - return result; + return result; } } return initial; } - export function reduceRight(array: T[], f: (a: T, x: T) => T): T; - export function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; - export function reduceRight(array: T[], f: (a: U, x: T) => U, initial?: U): U { + export function reduceRight(array: T[], f: (memo: U, value: T) => U, initial: U): U; + export function reduceRight(array: T[], f: (memo: T, value: T) => T): T; + export function reduceRight(array: T[], f: (memo: T, value: T) => T, initial?: T): T { if (array) { let pos = array.length - 1; if (pos >= 0) { - let result: T | U; + let result: T; if (arguments.length <= 2) { result = array[pos]; pos--; @@ -292,10 +292,10 @@ namespace ts { result = initial; } while (pos >= 0) { - result = f(result, array[pos]); + result = f(result, array[pos]); pos--; } - return result; + return result; } } return initial; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 12829a540e5..315f0777503 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -746,7 +746,7 @@ namespace ts { * @param nodes The NodeArray. */ function liftToBlock(nodes: NodeArray) { - Debug.assert(trueForAll(nodes, isStatement), "Cannot lift nodes to a Block."); + Debug.assert(every(nodes, isStatement), "Cannot lift nodes to a Block."); return createBlock(>nodes); } From 51dd27a7ecd5ca8add75f3cd491bc8d245aa67f7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 9 Feb 2016 11:43:25 -0800 Subject: [PATCH 2/2] Moved TreansformFlags assertions after markers --- src/compiler/types.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0b020839124..a9fae683718 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2749,13 +2749,6 @@ namespace ts { ES6 = 1 << 6, ContainsES6 = 1 << 7, - // Assertions - // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. - AssertTypeScript = TypeScript | ContainsTypeScript, - AssertJsx = Jsx | ContainsJsx, - AssertES7 = ES7 | ContainsES7, - AssertES6 = ES6 | ContainsES6, - // Markers // - Flags used to indicate that a subtree contains a specific transformation. ContainsDecorators = 1 << 8, @@ -2767,6 +2760,13 @@ namespace ts { ContainsSpreadElementExpression = 1 << 14, ContainsComputedPropertyName = 1 << 15, + // Assertions + // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. + AssertTypeScript = TypeScript | ContainsTypeScript, + AssertJsx = Jsx | ContainsJsx, + AssertES7 = ES7 | ContainsES7, + AssertES6 = ES6 | ContainsES6, + // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container.