Skip to content

Commit 89467d4

Browse files
committed
Added overloaded signatures to partition function.
1 parent e257fe8 commit 89467d4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/apollo-gateway/src/FieldSet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ function mergeFieldNodeSelectionSets(
138138
): SelectionNode[] {
139139
const [fieldNodes, fragmentNodes] = partition(
140140
selectionNodes,
141-
(node: SelectionNode): node is FieldNode => node.kind === Kind.FIELD,
141+
(node): node is FieldNode => node.kind === Kind.FIELD,
142142
);
143143

144144
const [aliasedFieldNodes, nonAliasedFieldNodes] = partition(
145145
fieldNodes,
146-
(node: FieldNode): node is FieldNode => !!node.alias,
146+
node => !!node.alias,
147147
);
148148

149149
const mergedFieldNodes = Array.from(

packages/apollo-gateway/src/utilities/array.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ export function compactMap<T, U>(
1919
export function partition<T, U extends T>(
2020
array: T[],
2121
predicate: (element: T, index: number, array: T[]) => element is U,
22-
): [U[], T[]] {
22+
): [U[], T[]];
23+
export function partition<T>(
24+
array: T[],
25+
predicate: (element: T, index: number, array: T[]) => boolean,
26+
): [T[], T[]];
27+
export function partition<T>(
28+
array: T[],
29+
predicate: (element: T, index: number, array: T[]) => boolean,
30+
): [T[], T[]] {
2331
array.map;
2432
return array.reduce(
2533
(accumulator, element, index) => {
@@ -30,7 +38,7 @@ export function partition<T, U extends T>(
3038
accumulator
3139
);
3240
},
33-
[[], []] as [U[], T[]],
41+
[[], []] as [T[], T[]],
3442
);
3543
}
3644

0 commit comments

Comments
 (0)