-
Notifications
You must be signed in to change notification settings - Fork 7
Arguments appears to be lossy when using spread syntax #19
Copy link
Copy link
Open
Description
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' };Perhaps I'm missing something, but I'd expect flow to complain about b?
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels