mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-16 14:40:50 -05:00
Remove 'indexOf' helper, use 'arr.indexOf()' (#20194)
This commit is contained in:
@@ -427,8 +427,9 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
else {
|
||||
const functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
const indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
if (indexOfParameter) {
|
||||
const indexOfParameter = functionDeclaration.parameters.indexOf(parameter);
|
||||
Debug.assert(indexOfParameter !== -1);
|
||||
if (indexOfParameter !== 0) {
|
||||
// Not a first parameter, go to previous parameter
|
||||
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
|
||||
}
|
||||
|
||||
@@ -367,12 +367,13 @@ namespace ts.formatting {
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
const containingList = getContainingList(node, sourceFile);
|
||||
return containingList ? getActualIndentationFromList(containingList) : Value.Unknown;
|
||||
|
||||
function getActualIndentationFromList(list: ReadonlyArray<Node>): number {
|
||||
const index = indexOf(list, node);
|
||||
return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : Value.Unknown;
|
||||
if (containingList) {
|
||||
const index = containingList.indexOf(node);
|
||||
if (index !== -1) {
|
||||
return deriveActualIndentationFromList(containingList, index, sourceFile, options);
|
||||
}
|
||||
}
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
function getLineIndentationWhenExpressionIsInMultiLine(node: Node, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace ts.JsDoc {
|
||||
function forEachUnique<T, U>(array: T[], callback: (element: T, index: number) => U): U {
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (indexOf(array, array[i]) === i) {
|
||||
if (array.indexOf(array[i]) === i) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user