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

Can't spread value with intersection-of-objects type #1329

Closed
samwgoldman opened this issue Jan 28, 2016 · 2 comments
Closed

Can't spread value with intersection-of-objects type #1329

samwgoldman opened this issue Jan 28, 2016 · 2 comments

Comments

@samwgoldman
Copy link
Member

/* @flow */

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

function foo(): T {
  return { foo: "", bar: "" }; // ok
}

function bar(x: T): void {
  (x.foo : string); // ok
  (x.bar : string); // ok

  let y: T = x; // ok
  let z: T = { ...x }; // error
}
test.js:3
  3: type T = { foo: string } & { bar: string };
                                ^^^^^^^^^^^^^^^ property `bar`. Property not found in
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ object literal. Trace:
* path 1:
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ MixedT [object literal]
  3: type T = { foo: string } & { bar: string };
                                ^^^^^^^^^^^^^^^  ~> LookupT [property `bar`] (from path 2)
* path 2:
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ObjT [object literal]
  3: type T = { foo: string } & { bar: string };
                                ^^^^^^^^^^^^^^^  ~> ObjT [object type] (from path 3)
* path 3:
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ObjT [object literal]
 14:   let z: T = { ...x }; // error
              ^ ~> IntersectionT [intersection type] (from path 4)
* path 4:
 14:   let z: T = { ...x }; // error
              ^ ReposUpperT [T]
  3: type T = { foo: string } & { bar: string };
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ~> IntersectionT [intersection type] (from path 5)
* path 5:
 14:   let z: T = { ...x }; // error
              ^ ReposUpperT [T]
 14:   let z: T = { ...x }; // error
              ^ ~> OpenT [T] (from path 6)
* path 6:
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ObjT [object literal]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> OpenT [assignment of var `z`] (from path 7)
 14:   let z: T = { ...x }; // error
              ^ ~> AnnotT [T]
* path 7:
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ObjT [object literal]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> OpenT [object literal] (from path 8)
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> ReposLowerT [assignment of var `z`]
* path 8:
  3: type T = { foo: string } & { bar: string };
              ^^^^^^^^^^^^^^^  ObjT [object type]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> ObjAssignT [object literal] (from path 9)
* path 9:
  3: type T = { foo: string } & { bar: string };
              ^^^^^^^^^^^^^^^  ObjT [object type]
 14:   let z: T = { ...x }; // error
                       ^ ~> SpeculativeMatchT [intersection: object type] (from path 10)
* path 10:
 14:   let z: T = { ...x }; // error
                       ^ IntersectionT [intersection type]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> ConcreteT [object literal] (from path 11)
* path 11:
 14:   let z: T = { ...x }; // error
                       ^ IntersectionT [intersection type]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> ObjAssignT [object literal] (from path 12)
* path 12:
 14:   let z: T = { ...x }; // error
                       ^ AnnotT [T]
 14:   let z: T = { ...x }; // error
                  ^^^^^^^^ ~> ObjAssignT [object literal] (from [not shown])
@chris-lock
Copy link

+1

@i-manolov
Copy link

is this issue being worked on currently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants