You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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",()=>{constts=`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 };
"
`;
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
I think the change is due to Flow changing the default of exact_by_default=true around 0.200.
declare var combination: Foo & Bar looks reasonable to me. Although you can also choose to interpreting all TS object types as exact, so that the spread can continue to work.
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:
The jest snapshot is now invalid:
Playground
I understand the principle that
Bar
has a spread and so could containfoo
of the wrong type, but what is the correct way to do this in flow so I can fix the logic? ThanksEdit: 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
The text was updated successfully, but these errors were encountered: