-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Hello. 👋 We use generated Flow types in our functions like this for example:
export default (room: ?BeddingInfo_room): string => {
// ...
};
Problem is that Relay is generating Flow types with +$refType
:
import type { ConcreteFragment } from 'relay-runtime';
import type { FragmentReference } from 'relay-runtime';
declare export opaque type BeddingInfo_room$ref: FragmentReference;
export type BeddingInfo_room = {|
+type: ?string,
+maxPersons: ?number,
+bedding: ?$ReadOnlyArray<?{|
+type: ?string,
+amount: ?number,
|}>,
+$refType: BeddingInfo_room$ref, // <<<
|};
This, unfortunately, complicates our testing because we cannot use simple plain objects (without the $refType
):
expect(
// Flow error here (vv) because Relay $refType is missing in the object
formatBeddingInfo({
type: 'Single Room',
maxPersons: 1,
bedding: [
{
type: 'Single Bed(s)',
amount: 1,
},
],
}),
).toMatchSnapshot();
I don't really understand why is this property necessary but is it possible to make it at least optional? Or how should we test it properly? It was fine before version 1.5... Error message:
Cannot call formatBeddingInfo with object literal bound to room because property $refType is missing in object
literal [1] but exists in BeddingInfo_room [2].
app/hotels/src/singleHotel/roomList/__tests__/formatBeddingInfo.test.js
4│
5│ it('formats bedding information', () => {
6│ expect(
[1] 7│ formatBeddingInfo({
8│ type: 'Single Room',
9│ maxPersons: 1,
10│ bedding: [
11│ {
12│ type: 'Single Bed(s)',
13│ amount: 1,
14│ },
15│ ],
16│ }),
17│ ).toMatchSnapshot();
18│ });
19│
app/hotels/src/singleHotel/roomList/formatBeddingInfo.js
[2] 7│ export default (room: ?BeddingInfo_room): string => {
tbergquist-godaddy, spyl94, juhaelee, jaroslav-kubicek, git-toni and 5 more
Metadata
Metadata
Assignees
Labels
No labels