Skip to content

Commit 468de8c

Browse files
committed
fix: support flowjs exact by default
1 parent 76e07b8 commit 468de8c

10 files changed

+80
-76
lines changed

.flowconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
[libs]
66

77
[lints]
8+
ambiguous-object-type=error
89

910
[options]
1011
well_formed_exports=true
1112
types_first=true
13+
; Fixes out of shared memory error for Mac Rosetta 2, see https://github.com/facebook/flow/issues/8538
14+
sharedmemory.heap_size=3221225472
1215

1316
[strict]

src/errorReporting/RuntimeTypeError.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type RuntimeTypeErrorItem from './RuntimeTypeErrorItem'
55
declare class RuntimeTypeError extends TypeError {
66
+errors: RuntimeTypeErrorItem[];
77
constructor(errors: RuntimeTypeErrorItem[]): void;
8-
formatMessage(options?: { limit?: number }): string;
8+
formatMessage(options?: { limit?: number, ... }): string;
99
}
1010

1111
export default RuntimeTypeError

src/index.js.flow

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ declare export function readonlyArray<T>(
7272
elementType: Type<T>
7373
): Type<$ReadOnlyArray<T>>
7474

75-
declare export function readonly<T: {}>(type: Type<T>): Type<$ReadOnly<T>>
75+
declare export function readonly<T: { ... }>(type: Type<T>): Type<$ReadOnly<T>>
7676

7777
declare export function nullLiteral(): Type<null>
7878
export { nullLiteral as null }
@@ -96,32 +96,32 @@ declare export function string(): Type<string>
9696
declare export function symbol<T: symbol>(literal: T): Type<T>
9797
declare export function symbol(): Type<symbol>
9898

99-
type ExtractPropertyTypes<P: { [any]: Type<any> }> = $Exact<
99+
type ExtractPropertyTypes<P: { [any]: Type<any>, ... }> = $Exact<
100100
$ObjMap<P, <T: Type<any>>(T) => $PropertyType<T, '__type'>>
101101
>
102-
type ExtractOptionalPropertyTypes<P: { [any]: Type<any> }> = $Exact<
102+
type ExtractOptionalPropertyTypes<P: { [any]: Type<any>, ... }> = $Exact<
103103
$Rest<ExtractPropertyTypes<P>, { ... }>
104104
>
105105

106-
declare export function object<R: { [any]: Type<any> }>({|
106+
declare export function object<R: { [any]: Type<any>, ... }>({|
107107
required: R,
108108
exact: false,
109109
|}): ObjectType<{ ...ExtractPropertyTypes<R>, ... }>
110-
declare export function object<R: { [any]: Type<any> }>({|
110+
declare export function object<R: { [any]: Type<any>, ... }>({|
111111
required: R,
112112
exact?: true,
113113
|}): ObjectType<ExtractPropertyTypes<R>>
114-
declare export function object<S: { [any]: Type<any> }>({|
114+
declare export function object<S: { [any]: Type<any>, ... }>({|
115115
optional: S,
116116
exact: false,
117117
|}): ObjectType<{ ...ExtractOptionalPropertyTypes<S>, ... }>
118-
declare export function object<S: { [any]: Type<any> }>({|
118+
declare export function object<S: { [any]: Type<any>, ... }>({|
119119
optional: S,
120120
exact?: true,
121121
|}): ObjectType<ExtractOptionalPropertyTypes<S>>
122122
declare export function object<
123-
R: { [any]: Type<any> },
124-
S: { [any]: Type<any> }
123+
R: { [any]: Type<any>, ... },
124+
S: { [any]: Type<any>, ... }
125125
>({|
126126
required: R,
127127
optional: S,
@@ -132,8 +132,8 @@ declare export function object<
132132
...
133133
}>
134134
declare export function object<
135-
R: { [any]: Type<any> },
136-
S: { [any]: Type<any> }
135+
R: { [any]: Type<any>, ... },
136+
S: { [any]: Type<any>, ... }
137137
>({|
138138
required: R,
139139
optional: S,
@@ -142,11 +142,11 @@ declare export function object<
142142
...ExtractPropertyTypes<R>,
143143
...ExtractOptionalPropertyTypes<S>,
144144
|}>
145-
declare export function object<R: { [any]: Type<any> }>(
145+
declare export function object<R: { [any]: Type<any>, ... }>(
146146
required: R
147147
): ObjectType<ExtractPropertyTypes<R>>
148148

149-
type Properties = { [string | number | symbol]: Type<any> }
149+
type Properties = { [string | number | symbol]: Type<any>, ... }
150150

151151
declare export function record<K: string | number | symbol, V>(
152152
key: Type<K>,

src/merge.js.flow

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
import Type from './types/Type'
44

5-
declare export default function merge<T1: {}>(
5+
declare export default function merge<T1: { ... }>(
66
t1: Type<T1>
77
): Type<{| ...$Exact<T1> |}>
8-
declare export default function merge<T1: {}, T2: {}>(
8+
declare export default function merge<T1: { ... }, T2: { ... }>(
99
t1: Type<T1>,
1010
t2: Type<T2>
1111
): Type<{| ...$Exact<T1>, ...$Exact<T2> |}>
12-
declare export default function merge<T1: {}, T2: {}, T3: {}>(
12+
declare export default function merge<T1: { ... }, T2: { ... }, T3: { ... }>(
1313
t1: Type<T1>,
1414
t2: Type<T2>,
1515
t3: Type<T3>
1616
): Type<{| ...$Exact<T1>, ...$Exact<T2>, ...$Exact<T3> |}>
17-
declare export default function merge<T1: {}, T2: {}, T3: {}, T4: {}>(
17+
declare export default function merge<T1: { ... }, T2: { ... }, T3: { ... }, T4: { ... }>(
1818
t1: Type<T1>,
1919
t2: Type<T2>,
2020
t3: Type<T3>,
2121
t4: Type<T4>
2222
): Type<{| ...$Exact<T1>, ...$Exact<T2>, ...$Exact<T3>, ...$Exact<T4> |}>
23-
declare export default function merge<T1: {}, T2: {}, T3: {}, T4: {}, T5: {}>(
23+
declare export default function merge<T1: { ... }, T2: { ... }, T3: { ... }, T4: { ... }, T5: { ... }>(
2424
t1: Type<T1>,
2525
t2: Type<T2>,
2626
t3: Type<T3>,
@@ -34,12 +34,12 @@ declare export default function merge<T1: {}, T2: {}, T3: {}, T4: {}, T5: {}>(
3434
...$Exact<T5>,
3535
|}>
3636
declare export default function merge<
37-
T1: {},
38-
T2: {},
39-
T3: {},
40-
T4: {},
41-
T5: {},
42-
T6: {}
37+
T1: { ... },
38+
T2: { ... },
39+
T3: { ... },
40+
T4: { ... },
41+
T5: { ... },
42+
T6: { ... }
4343
>(
4444
t1: Type<T1>,
4545
t2: Type<T2>,
@@ -56,13 +56,13 @@ declare export default function merge<
5656
...$Exact<T6>,
5757
|}>
5858
declare export default function merge<
59-
T1: {},
60-
T2: {},
61-
T3: {},
62-
T4: {},
63-
T5: {},
64-
T6: {},
65-
T7: {}
59+
T1: { ... },
60+
T2: { ... },
61+
T3: { ... },
62+
T4: { ... },
63+
T5: { ... },
64+
T6: { ... },
65+
T7: { ... }
6666
>(
6767
t1: Type<T1>,
6868
t2: Type<T2>,
@@ -81,14 +81,14 @@ declare export default function merge<
8181
...$Exact<T7>,
8282
|}>
8383
declare export default function merge<
84-
T1: {},
85-
T2: {},
86-
T3: {},
87-
T4: {},
88-
T5: {},
89-
T6: {},
90-
T7: {},
91-
T8: {}
84+
T1: { ... },
85+
T2: { ... },
86+
T3: { ... },
87+
T4: { ... },
88+
T5: { ... },
89+
T6: { ... },
90+
T7: { ... },
91+
T8: { ... }
9292
>(
9393
t1: Type<T1>,
9494
t2: Type<T2>,
@@ -109,4 +109,4 @@ declare export default function merge<
109109
...$Exact<T8>,
110110
|}>
111111

112-
declare export default function merge(...types: Type<{}>[]): Type<{}>
112+
declare export default function merge(...types: Type<{ ... }>[]): Type<{ ... }>

src/mergeInexact.js.flow

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
import Type from './types/Type'
44

5-
declare export default function mergeInexact<T1: {}>(
5+
declare export default function mergeInexact<T1: { ... }>(
66
t1: Type<T1>
77
): Type<{ ...$Exact<T1>, ... }>
8-
declare export default function mergeInexact<T1: {}, T2: {}>(
8+
declare export default function mergeInexact<T1: { ... }, T2: { ... }>(
99
t1: Type<T1>,
1010
t2: Type<T2>
1111
): Type<{ ...$Exact<T1>, ...$Exact<T2>, ... }>
12-
declare export default function mergeInexact<T1: {}, T2: {}, T3: {}>(
12+
declare export default function mergeInexact<T1: { ... }, T2: { ... }, T3: { ... }>(
1313
t1: Type<T1>,
1414
t2: Type<T2>,
1515
t3: Type<T3>
1616
): Type<{ ...$Exact<T1>, ...$Exact<T2>, ...$Exact<T3>, ... }>
17-
declare export default function mergeInexact<T1: {}, T2: {}, T3: {}, T4: {}>(
17+
declare export default function mergeInexact<T1: { ... }, T2: { ... }, T3: { ... }, T4: { ... }>(
1818
t1: Type<T1>,
1919
t2: Type<T2>,
2020
t3: Type<T3>,
2121
t4: Type<T4>
2222
): Type<{ ...$Exact<T1>, ...$Exact<T2>, ...$Exact<T3>, ...$Exact<T4>, ... }>
2323
declare export default function mergeInexact<
24-
T1: {},
25-
T2: {},
26-
T3: {},
27-
T4: {},
28-
T5: {}
24+
T1: { ... },
25+
T2: { ... },
26+
T3: { ... },
27+
T4: { ... },
28+
T5: { ... }
2929
>(
3030
t1: Type<T1>,
3131
t2: Type<T2>,
@@ -41,12 +41,12 @@ declare export default function mergeInexact<
4141
...
4242
}>
4343
declare export default function mergeInexact<
44-
T1: {},
45-
T2: {},
46-
T3: {},
47-
T4: {},
48-
T5: {},
49-
T6: {}
44+
T1: { ... },
45+
T2: { ... },
46+
T3: { ... },
47+
T4: { ... },
48+
T5: { ... },
49+
T6: { ... }
5050
>(
5151
t1: Type<T1>,
5252
t2: Type<T2>,
@@ -64,13 +64,13 @@ declare export default function mergeInexact<
6464
...
6565
}>
6666
declare export default function mergeInexact<
67-
T1: {},
68-
T2: {},
69-
T3: {},
70-
T4: {},
71-
T5: {},
72-
T6: {},
73-
T7: {}
67+
T1: { ... },
68+
T2: { ... },
69+
T3: { ... },
70+
T4: { ... },
71+
T5: { ... },
72+
T6: { ... },
73+
T7: { ... }
7474
>(
7575
t1: Type<T1>,
7676
t2: Type<T2>,
@@ -90,14 +90,14 @@ declare export default function mergeInexact<
9090
...
9191
}>
9292
declare export default function mergeInexact<
93-
T1: {},
94-
T2: {},
95-
T3: {},
96-
T4: {},
97-
T5: {},
98-
T6: {},
99-
T7: {},
100-
T8: {}
93+
T1: { ... },
94+
T2: { ... },
95+
T3: { ... },
96+
T4: { ... },
97+
T5: { ... },
98+
T6: { ... },
99+
T7: { ... },
100+
T8: { ... }
101101
>(
102102
t1: Type<T1>,
103103
t2: Type<T2>,
@@ -119,4 +119,4 @@ declare export default function mergeInexact<
119119
...
120120
}>
121121

122-
declare export default function mergeInexact(...types: Type<{}>[]): Type<{}>
122+
declare export default function mergeInexact(...types: Type<{ ... }>[]): Type<{ ... }>

src/types/MergedObjectType.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Type from './Type'
44

5-
declare export default class MergedObjectType<T: {}> extends Type<T> {
5+
declare export default class MergedObjectType<T: { ... }> extends Type<T> {
66
objects: Type<T>[];
77
exact: boolean;
88

src/types/ObjectType.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Type from './Type'
44

55
import ObjectTypeProperty from './ObjectTypeProperty'
66

7-
declare class ObjectType<T: {}> extends Type<T> {
7+
declare class ObjectType<T: { ... }> extends Type<T> {
88
properties: ObjectTypeProperty<$Keys<T>, any>[];
99
exact: boolean;
1010

src/types/ObjectTypeProperty.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare class ObjectTypeProperty<
1616
/**
1717
* Determine whether the property exists on the given input or its prototype chain.
1818
*/
19-
existsOn(input: { [string]: any }): boolean;
19+
existsOn(input: { [string]: any, ... }): boolean;
2020
}
2121

2222
export default ObjectTypeProperty

src/types/RecordType.js.flow

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Type from './Type'
44

55
declare class RecordType<K: string | number | symbol, V> extends Type<{
66
[K]: V,
7+
...
78
}> {
89
key: Type<K>;
910
value: Type<V>;

src/types/Type.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare class Type<T> {
2727

2828
validate(input: any, prefix?: string, path?: IdentifierPath): Validation;
2929

30-
toString(options?: { formatForMustBe?: boolean }): string;
30+
toString(options?: { formatForMustBe?: boolean, ... }): string;
3131
}
3232

3333
export default Type

0 commit comments

Comments
 (0)