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

Intersection type bugs meta-issue #1331

Open
3 of 4 tasks
samwgoldman opened this issue Jan 28, 2016 · 2 comments
Open
3 of 4 tasks

Intersection type bugs meta-issue #1331

samwgoldman opened this issue Jan 28, 2016 · 2 comments

Comments

@samwgoldman
Copy link
Member

@machadogj
Copy link

Intersection types are awfully useful when working with react and passing down props from bigger components to smaller more specialised ones, however the lack of support for spread operator makes it very hard to work with (unless I'm missing something).

I noticed #1329 is "checked" and the issue has been closed in March. Does it mean it's been solved? If so, in which version/branch can we access this feature?

Thanks!

@machadogj
Copy link

Looks like one of the scenarios has been fixed in 0.50.0:

function bar(x: T): void {
  let z: T = { ...x }; // error - now fixed in 0.50.0
}

But the following seems to be problematic:

/* @flow */

type T = { foo: string } & { bar: number };

function bam({bar}: {bar: number}): number {
  return bar + 2;
}

function bar(x: T): void {
  let { foo, ...props } = x;
  bam(props); //error
}

Here's the reported error:

5: function bam({bar}: {bar: number}): number {
                       ^ property `bar`. Property not found in
11:   bam(props); //error
          ^ rest of object pattern

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

5 participants
@mroch @samwgoldman @machadogj @goodmind and others