diff --git a/.eslintrc.yml b/.eslintrc.yml index 667104f..614a66c 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -455,7 +455,7 @@ overrides: flowtype/no-unused-expressions: off flowtype/no-weak-types: [error, { any: false }] flowtype/require-compound-type-alias: off - flowtype/require-exact-type: off + flowtype/require-exact-type: [error, never] flowtype/require-indexer-name: error flowtype/require-inexact-type: off # checked by Flow flowtype/require-parameter-type: off diff --git a/.flowconfig b/.flowconfig index 51947ce..0e640fb 100644 --- a/.flowconfig +++ b/.flowconfig @@ -9,10 +9,7 @@ /node_modules/graphql [lints] -sketchy-null-bool=error -sketchy-null-string=error -sketchy-null-number=error -sketchy-null-mixed=error +sketchy-null=error sketchy-number=error untyped-type-import=error nonstrict-import=off @@ -25,7 +22,7 @@ unnecessary-optional-chain=error unnecessary-invariant=error signature-verification-failure=error implicit-inexact-object=error -ambiguous-object-type=error +ambiguous-object-type=off uninitialized-instance-property=error default-import-access=error invalid-import-star-use=error @@ -37,6 +34,7 @@ export-renamed-default=error [options] all=true module.use_strict=true +exact_by_default=true babel_loose_array_spread=true experimental.const_params=true include_warnings=true diff --git a/src/__tests__/starWarsData.js b/src/__tests__/starWarsData.js index 5873ac6..832551c 100644 --- a/src/__tests__/starWarsData.js +++ b/src/__tests__/starWarsData.js @@ -6,10 +6,10 @@ * JSON objects in a more complex demo. */ -type Ship = {| +type Ship = { id: string, name: string, -|}; +}; const allShips: Array = [ { id: '1', name: 'X-Wing' }, @@ -25,11 +25,11 @@ const allShips: Array = [ { id: '8', name: 'Executor' }, ]; -type Faction = {| +type Faction = { id: string, name: string, ships: Array, -|}; +}; const rebels: Faction = { id: '1', diff --git a/src/connection/arrayConnection.js b/src/connection/arrayConnection.js index f4adff8..a172973 100644 --- a/src/connection/arrayConnection.js +++ b/src/connection/arrayConnection.js @@ -6,10 +6,10 @@ import type { ConnectionCursor, } from './connection'; -type ArraySliceMetaInfo = {| +type ArraySliceMetaInfo = { sliceStart: number, arrayLength: number, -|}; +}; /** * A simple function that accepts an array and connection arguments, and returns diff --git a/src/connection/connection.js b/src/connection/connection.js index 5a854fa..0723d6b 100644 --- a/src/connection/connection.js +++ b/src/connection/connection.js @@ -73,19 +73,19 @@ export type ConnectionArguments = { ... }; -type ConnectionConfig = {| +type ConnectionConfig = { name?: string, nodeType: GraphQLNamedType | GraphQLNonNull, resolveNode?: GraphQLFieldResolver, resolveCursor?: GraphQLFieldResolver, edgeFields?: Thunk>, connectionFields?: Thunk>, -|}; +}; -type GraphQLConnectionDefinitions = {| +type GraphQLConnectionDefinitions = { edgeType: GraphQLObjectType, connectionType: GraphQLObjectType, -|}; +}; function resolveMaybeThunk(thingOrThunk: Thunk): T { return typeof thingOrThunk === 'function' @@ -143,18 +143,18 @@ export function connectionDefinitions( /** * A type designed to be exposed as a `Connection` over GraphQL. */ -export type Connection = {| +export type Connection = { edges: Array>, pageInfo: PageInfo, -|}; +}; /** * A type designed to be exposed as a `Edge` over GraphQL. */ -export type Edge = {| +export type Edge = { node: T, cursor: ConnectionCursor, -|}; +}; /** * The common page info type used by all connections. @@ -185,9 +185,9 @@ const pageInfoType = new GraphQLObjectType({ /** * A type designed to be exposed as `PageInfo` over GraphQL. */ -export type PageInfo = {| +export type PageInfo = { startCursor: ConnectionCursor | null, endCursor: ConnectionCursor | null, hasPreviousPage: boolean, hasNextPage: boolean, -|}; +}; diff --git a/src/mutation/mutation.js b/src/mutation/mutation.js index 8ccef30..2a62a39 100644 --- a/src/mutation/mutation.js +++ b/src/mutation/mutation.js @@ -38,7 +38,7 @@ function resolveMaybeThunk(thingOrThunk: Thunk): T { * input field, and it should return an Object with a key for each * output field. It may return synchronously, or return a Promise. */ -type MutationConfig = {| +type MutationConfig = { name: string, description?: string, deprecationReason?: string, @@ -46,7 +46,7 @@ type MutationConfig = {| inputFields: Thunk, outputFields: Thunk>, mutateAndGetPayload: MutationFn, -|}; +}; /** * Returns a GraphQLFieldConfig for the mutation described by the diff --git a/src/node/node.js b/src/node/node.js index 0efefae..b76eddf 100644 --- a/src/node/node.js +++ b/src/node/node.js @@ -13,11 +13,11 @@ import type { import { base64, unbase64 } from '../utils/base64'; -type GraphQLNodeDefinitions = {| +type GraphQLNodeDefinitions = { nodeInterface: GraphQLInterfaceType, nodeField: GraphQLFieldConfig, nodesField: GraphQLFieldConfig, -|}; +}; /** * Given a function to map from an ID to an underlying object, and a function @@ -75,10 +75,10 @@ export function nodeDefinitions( return { nodeInterface, nodeField, nodesField }; } -type ResolvedGlobalId = {| +type ResolvedGlobalId = { type: string, id: string, -|}; +}; /** * Takes a type name and an ID specific to that type name, and returns a diff --git a/src/node/plural.js b/src/node/plural.js index 512d424..6d0f2f1 100644 --- a/src/node/plural.js +++ b/src/node/plural.js @@ -7,7 +7,7 @@ import type { GraphQLResolveInfo, } from 'graphql'; -type PluralIdentifyingRootFieldConfig = {| +type PluralIdentifyingRootFieldConfig = { argName: string, inputType: GraphQLInputType, outputType: GraphQLOutputType, @@ -17,7 +17,7 @@ type PluralIdentifyingRootFieldConfig = {| info: GraphQLResolveInfo, ) => mixed, description?: string, -|}; +}; export function pluralIdentifyingRootField( config: PluralIdentifyingRootFieldConfig,