Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$Compose/$ComposeReverse isn't a subtype of (...any) => any #7874

Closed
Bannerets opened this issue Jul 2, 2019 · 1 comment
Closed

$Compose/$ComposeReverse isn't a subtype of (...any) => any #7874

Bannerets opened this issue Jul 2, 2019 · 1 comment

Comments

@Bannerets
Copy link

Bannerets commented Jul 2, 2019

Flow version: v0.102.0

// @flow
declare var c1: $Compose
;(c1: (...args: any) => any) // error
declare var c2: $ComposeReverse
;(c2: (...args: any) => any) // error

try flow

Actual behavior

I see the weird Cannot cast c1 to function type because function type [1] is incompatible with function type errors.

Expected behavior

$Compose behaves like a function, so I expect it to be a subtype of (...args: any) => any.

Also, If it will be fixed, it allows creation of $TupleReduce via $TupleMap:

Example
// @flow

declare function apply<Args, R>(f: (...Args) => R, ...args: Args): R
type _Apply = typeof apply
type Apply<Fn, Args> = $Call<_Apply, Fn, Args>

declare function reduce<Fn, A, T>(Fn, A, T): $Call<
  Apply<
    $Compose,
    $TupleMap<T, Fn>,
  >
, A>
type _Reduce = typeof reduce

export type Reduce<Fn, A, T> = $Call<_Reduce, Fn, A, T>

type MergeAll<T> = Reduce<<X, V>(V) => ((X) => ({...$Exact<X>, ...$Exact<V>})), {}, T>

declare function mergeAll<A>(A): MergeAll<A>

const x = mergeAll([{a: 1}, {b: 1}, {c: 1}])

;(x: {a: 1, b: 1, c: 1})

;(x: {a: 1, b: 1, c: '1'}) // error

try flow


  • Link to Try-Flow or Github repo: link
@SamChou19815
Copy link
Contributor

Closing since support for these types is removed in 0.232

@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants