Use find array helper (#18557)

* Use `find` array helper

* Provide explicit type argument to `find`
This commit is contained in:
Andy 2017-09-19 08:27:31 -07:00 committed by GitHub
parent 21bbee4044
commit 951974dff6

View File

@ -934,12 +934,8 @@ namespace ts.refactor.extractMethod {
* Otherwise, return `undefined`.
*/
function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined {
const children = getStatementsOrClassElements(scope);
for (const child of children) {
if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) {
return child;
}
}
return find<Statement | ClassElement>(getStatementsOrClassElements(scope), child =>
child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child));
}
function getPropertyAssignmentsForWrites(writes: ReadonlyArray<UsageEntry>): ShorthandPropertyAssignment[] {