Giter VIP home page Giter VIP logo

flown's Issues

Error when Reduce is used more than one-time

When a function that uses Reduce type is called more than one-time, flow error occurs:

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 }, { a: 2 }])
const xx = mergeAll([{ a: 1 }, { b: 1 }, { c: 1 }, { a: 2 }])

// try to comment this line, the error disappears
;(x: { a: 2, b: 1, c: 1 }) // rightly

// or try to comment this line, the error disappears too
;(xx: { a: 2, b: 1, c: 1 }) // error?!

Link to repl

This is really cool

Hey, no issue, just wanted to let you know that this is really cool!! Thank you for sharing!

`Arguments` appears to be lossy when using spread syntax

First of - thanks @lttb so much for this library! It's a huge help!

I'm running into the following issue best demonstrated by a small repro:

type GetUserInfoArgs = {| user_id: number |};
type GetUserInfo = (GetUserInfoArgs) => { first_name: string, last_name: string };
type DerivedArg = $ElementType<Arguments<GetUserInfo>, 0>; // should be equivalent to `GetUserInfoArgs`?

/**
 * Using Arguments<GetUserInfo>:
 * - `a` fails type checking as expected
 * - `b` does not fail type checking :( 
 */
const a: DerivedArg = { foo: 'bar' };
const b: {| ...DerivedArg |} = { foo: 'bar' };

/**
 * Without using Arguments<GetUserInfo>:
 * - `c` fails type checking as expected
 * - `d` fails type checking as expected 
 */
const c: GetUserInfoArgs = { foo: 'bar' };
const d: {| ...GetUserInfoArgs |} = { foo: 'bar' };

Link to full repro in tryflow

Perhaps I'm missing something, but I'd expect flow to complain about b?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.