diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b7edcfc5473..5f68777a63b 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/types.ts b/src/compiler/types.ts index 39ee80b7b00..23c46a71a58 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2755,13 +2755,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, @@ -2773,6 +2766,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. diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index eec487a7ebc..94faf7b1e10 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -755,7 +755,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); }