Skip to content

[Question]: How to fix flowgen test after flow update #9090

@dominictobias

Description

@dominictobias

What do you want to know?

I'm updating a couple of things in flowgen (since Flow now supports most of the missing utils)

After updating flow-bin to 0.217, this test started to fail:

it("should use spread when performing union of object types", () => {
  const ts = `
type Foo = { foo: number };
type Bar = { bar: string };
const combination: Foo & Bar;
`;
 // ...

The jest snapshot is now invalid:

exports[`should use spread when performing union of object types 1`] = `
"declare type Foo = {
  foo: number,
  ...
};
declare type Bar = {
  bar: string,
  ...
};
declare var combination: { ...Foo, ...Bar };
"
`;

Playground

I understand the principle that Bar has a spread and so could contain foo of the wrong type, but what is the correct way to do this in flow so I can fix the logic? Thanks

Edit: Looking at intersections/#toc-intersections-of-object-types it seems like the correct output should be declare var combination: Foo & Bar?

Edit edit: Assume that's correct, raised a PR: joarwilk/flowgen#201

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions