diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 605cde05178..a3910334286 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -702,7 +702,7 @@ namespace ts { function deduplicateRelational(array: ReadonlyArray, equalityComparer: EqualityComparer, comparer: Comparer) { // Perform a stable sort of the array. This ensures the first entry in a list of // duplicates remains the first entry in the result. - const indices = sequence(0, array.length); + const indices = array.map((_, i) => i); stableSortIndices(array, indices, comparer); let last = array[indices[0]]; @@ -895,17 +895,6 @@ namespace ts { } } - /** - * Creates an array of integers starting at `from` (inclusive) and ending at `to` (exclusive). - */ - function sequence(from: number, to: number) { - const numbers: number[] = []; - for (let i = from; i < to; i++) { - numbers.push(i); - } - return numbers; - } - function stableSortIndices(array: ReadonlyArray, indices: number[], comparer: Comparer) { // sort indices by value then position indices.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y)); @@ -922,7 +911,7 @@ namespace ts { * Stable sort of an array. Elements equal to each other maintain their relative position in the array. */ export function stableSort(array: ReadonlyArray, comparer: Comparer) { - const indices = sequence(0, array.length); + const indices = array.map((_, i) => i); stableSortIndices(array, indices, comparer); return indices.map(i => array[i]) as ReadonlyArray as SortedReadonlyArray; } @@ -1009,7 +998,7 @@ namespace ts { * @param array A sorted array whose first element must be no larger than number * @param number The value to be searched for in the array. */ - export function binarySearch(array: ReadonlyArray, value: T, keySelector: Selector, keyComparer: Comparer, offset?: number): number { + export function binarySearch(array: ReadonlyArray, value: T, keySelector: (v: T) => U, keyComparer: Comparer, offset?: number): number { if (!array || array.length === 0) { return -1; } @@ -1764,8 +1753,8 @@ namespace ts { } })(); - let uiCS: Comparer | undefined; - let uiCI: Comparer | undefined; + let uiComparerCaseSensitive: Comparer | undefined; + let uiComparerCaseInsensitive: Comparer | undefined; let uiLocale: string | undefined; export function getUILocale() { @@ -1775,8 +1764,8 @@ namespace ts { export function setUILocale(value: string) { if (uiLocale !== value) { uiLocale = value; - uiCS = undefined; - uiCI = undefined; + uiComparerCaseSensitive = undefined; + uiComparerCaseInsensitive = undefined; } } @@ -1791,7 +1780,7 @@ namespace ts { * accents/diacritic marks as unequal. */ export function compareStringsCaseInsensitiveUI(a: string, b: string) { - const comparer = uiCI || (uiCI = createStringComparer(uiLocale, /*caseInsensitive*/ true)); + const comparer = uiComparerCaseInsensitive || (uiComparerCaseInsensitive = createStringComparer(uiLocale, /*caseInsensitive*/ true)); return comparer(a, b); } @@ -1806,7 +1795,7 @@ namespace ts { * accents/diacritic marks, or case as unequal. */ export function compareStringsCaseSensitiveUI(a: string, b: string) { - const comparer = uiCS || (uiCS = createStringComparer(uiLocale, /*caseInsensitive*/ false)); + const comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createStringComparer(uiLocale, /*caseInsensitive*/ false)); return comparer(a, b); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3af3b6e022a..84028a23b0a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -54,9 +54,6 @@ namespace ts { GreaterThan = 1 } - /* @internal */ - export type Selector = (v: T) => U; - // branded string type used to store absolute, normalized and canonicalized paths // arbitrary file name can be converted to Path via toPath function export type Path = string & { __pathBrand: any }; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b52dbd6932a..d88f0e0854e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3129,7 +3129,6 @@ Actual: ${stringify(fullActual)}`); ${code} })`; try { - const test = new FourSlashInterface.Test(state); const goTo = new FourSlashInterface.GoTo(state); const verify = new FourSlashInterface.Verify(state); diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 57955c9ab43..6ae94790e1b 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -208,8 +208,11 @@ function beginTests() { } // run tests in en-US by default. - const savedUILocale = ts.getUILocale(); - beforeEach(() => ts.setUILocale("en-US")); + let savedUILocale: string | undefined; + beforeEach(() => { + savedUILocale = ts.getUILocale(); + ts.setUILocale("en-US"); + }); afterEach(() => ts.setUILocale(savedUILocale)); runTests(runners);