Skip to content

Commit e8e849f

Browse files
cellogtimdorr
authored andcommitted
convert compose to typescript (reduxjs#3532)
Former-commit-id: f15d63e Former-commit-id: 6b739b8
1 parent 895e2b3 commit e8e849f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compose.js renamed to src/compose.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
* (...args) => f(g(h(...args))).
1010
*/
1111

12-
export default function compose(...funcs) {
12+
export default function compose(...funcs: Function[]) {
1313
if (funcs.length === 0) {
14-
return arg => arg
14+
// infer the argument type so it is usable in inference down the line
15+
return <T>(arg: T) => arg
1516
}
1617

1718
if (funcs.length === 1) {
1819
return funcs[0]
1920
}
2021

21-
return funcs.reduce((a, b) => (...args) => a(b(...args)))
22+
return funcs.reduce((a, b) => (...args: any) => a(b(...args)))
2223
}

0 commit comments

Comments
 (0)