Skip to content

Commit 1723186

Browse files
Flow: switched to exact object by default (#351)
1 parent a53d562 commit 1723186

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ overrides:
455455
flowtype/no-unused-expressions: off
456456
flowtype/no-weak-types: [error, { any: false }]
457457
flowtype/require-compound-type-alias: off
458-
flowtype/require-exact-type: off
458+
flowtype/require-exact-type: [error, never]
459459
flowtype/require-indexer-name: error
460460
flowtype/require-inexact-type: off # checked by Flow
461461
flowtype/require-parameter-type: off

.flowconfig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
<PROJECT_ROOT>/node_modules/graphql
1010

1111
[lints]
12-
sketchy-null-bool=error
13-
sketchy-null-string=error
14-
sketchy-null-number=error
15-
sketchy-null-mixed=error
12+
sketchy-null=error
1613
sketchy-number=error
1714
untyped-type-import=error
1815
nonstrict-import=off
@@ -25,7 +22,7 @@ unnecessary-optional-chain=error
2522
unnecessary-invariant=error
2623
signature-verification-failure=error
2724
implicit-inexact-object=error
28-
ambiguous-object-type=error
25+
ambiguous-object-type=off
2926
uninitialized-instance-property=error
3027
default-import-access=error
3128
invalid-import-star-use=error
@@ -37,6 +34,7 @@ export-renamed-default=error
3734
[options]
3835
all=true
3936
module.use_strict=true
37+
exact_by_default=true
4038
babel_loose_array_spread=true
4139
experimental.const_params=true
4240
include_warnings=true

src/__tests__/starWarsData.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* JSON objects in a more complex demo.
77
*/
88

9-
type Ship = {|
9+
type Ship = {
1010
id: string,
1111
name: string,
12-
|};
12+
};
1313

1414
const allShips: Array<Ship> = [
1515
{ id: '1', name: 'X-Wing' },
@@ -25,11 +25,11 @@ const allShips: Array<Ship> = [
2525
{ id: '8', name: 'Executor' },
2626
];
2727

28-
type Faction = {|
28+
type Faction = {
2929
id: string,
3030
name: string,
3131
ships: Array<string>,
32-
|};
32+
};
3333

3434
const rebels: Faction = {
3535
id: '1',

src/connection/arrayConnection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type {
66
ConnectionCursor,
77
} from './connection';
88

9-
type ArraySliceMetaInfo = {|
9+
type ArraySliceMetaInfo = {
1010
sliceStart: number,
1111
arrayLength: number,
12-
|};
12+
};
1313

1414
/**
1515
* A simple function that accepts an array and connection arguments, and returns

src/connection/connection.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ export type ConnectionArguments = {
7373
...
7474
};
7575

76-
type ConnectionConfig = {|
76+
type ConnectionConfig = {
7777
name?: string,
7878
nodeType: GraphQLNamedType | GraphQLNonNull<GraphQLNamedType>,
7979
resolveNode?: GraphQLFieldResolver<any, any>,
8080
resolveCursor?: GraphQLFieldResolver<any, any>,
8181
edgeFields?: Thunk<GraphQLFieldConfigMap<any, any>>,
8282
connectionFields?: Thunk<GraphQLFieldConfigMap<any, any>>,
83-
|};
83+
};
8484

85-
type GraphQLConnectionDefinitions = {|
85+
type GraphQLConnectionDefinitions = {
8686
edgeType: GraphQLObjectType,
8787
connectionType: GraphQLObjectType,
88-
|};
88+
};
8989

9090
function resolveMaybeThunk<T>(thingOrThunk: Thunk<T>): T {
9191
return typeof thingOrThunk === 'function'
@@ -143,18 +143,18 @@ export function connectionDefinitions(
143143
/**
144144
* A type designed to be exposed as a `Connection` over GraphQL.
145145
*/
146-
export type Connection<T> = {|
146+
export type Connection<T> = {
147147
edges: Array<Edge<T>>,
148148
pageInfo: PageInfo,
149-
|};
149+
};
150150

151151
/**
152152
* A type designed to be exposed as a `Edge` over GraphQL.
153153
*/
154-
export type Edge<T> = {|
154+
export type Edge<T> = {
155155
node: T,
156156
cursor: ConnectionCursor,
157-
|};
157+
};
158158

159159
/**
160160
* The common page info type used by all connections.
@@ -185,9 +185,9 @@ const pageInfoType = new GraphQLObjectType({
185185
/**
186186
* A type designed to be exposed as `PageInfo` over GraphQL.
187187
*/
188-
export type PageInfo = {|
188+
export type PageInfo = {
189189
startCursor: ConnectionCursor | null,
190190
endCursor: ConnectionCursor | null,
191191
hasPreviousPage: boolean,
192192
hasNextPage: boolean,
193-
|};
193+
};

src/mutation/mutation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ function resolveMaybeThunk<T>(thingOrThunk: Thunk<T>): T {
3838
* input field, and it should return an Object with a key for each
3939
* output field. It may return synchronously, or return a Promise.
4040
*/
41-
type MutationConfig = {|
41+
type MutationConfig = {
4242
name: string,
4343
description?: string,
4444
deprecationReason?: string,
4545
extensions?: { [name: string]: mixed },
4646
inputFields: Thunk<GraphQLInputFieldConfigMap>,
4747
outputFields: Thunk<GraphQLFieldConfigMap<any, any>>,
4848
mutateAndGetPayload: MutationFn,
49-
|};
49+
};
5050

5151
/**
5252
* Returns a GraphQLFieldConfig for the mutation described by the

src/node/node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import type {
1313

1414
import { base64, unbase64 } from '../utils/base64';
1515

16-
type GraphQLNodeDefinitions<TContext> = {|
16+
type GraphQLNodeDefinitions<TContext> = {
1717
nodeInterface: GraphQLInterfaceType,
1818
nodeField: GraphQLFieldConfig<mixed, TContext>,
1919
nodesField: GraphQLFieldConfig<mixed, TContext>,
20-
|};
20+
};
2121

2222
/**
2323
* Given a function to map from an ID to an underlying object, and a function
@@ -75,10 +75,10 @@ export function nodeDefinitions<TContext>(
7575
return { nodeInterface, nodeField, nodesField };
7676
}
7777

78-
type ResolvedGlobalId = {|
78+
type ResolvedGlobalId = {
7979
type: string,
8080
id: string,
81-
|};
81+
};
8282

8383
/**
8484
* Takes a type name and an ID specific to that type name, and returns a

src/node/plural.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
GraphQLResolveInfo,
88
} from 'graphql';
99

10-
type PluralIdentifyingRootFieldConfig = {|
10+
type PluralIdentifyingRootFieldConfig = {
1111
argName: string,
1212
inputType: GraphQLInputType,
1313
outputType: GraphQLOutputType,
@@ -17,7 +17,7 @@ type PluralIdentifyingRootFieldConfig = {|
1717
info: GraphQLResolveInfo,
1818
) => mixed,
1919
description?: string,
20-
|};
20+
};
2121

2222
export function pluralIdentifyingRootField(
2323
config: PluralIdentifyingRootFieldConfig,

0 commit comments

Comments
 (0)