Skip to content

Commit 951974d

Browse files
author
Andy
authored
Use find array helper (#18557)
* Use `find` array helper * Provide explicit type argument to `find`
1 parent 21bbee4 commit 951974d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/services/refactors/extractMethod.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,8 @@ namespace ts.refactor.extractMethod {
934934
* Otherwise, return `undefined`.
935935
*/
936936
function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined {
937-
const children = getStatementsOrClassElements(scope);
938-
for (const child of children) {
939-
if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) {
940-
return child;
941-
}
942-
}
937+
return find<Statement | ClassElement>(getStatementsOrClassElements(scope), child =>
938+
child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child));
943939
}
944940

945941
function getPropertyAssignmentsForWrites(writes: ReadonlyArray<UsageEntry>): ShorthandPropertyAssignment[] {

0 commit comments

Comments
 (0)