Skip to content

Commit 8bc06ca

Browse files
committed
Remove flow option experimental.const_params
Merges #1157 Codebases which don't enable this experiment show flow errors
1 parent 026870c commit 8bc06ca

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.flowconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[libs]
1010

1111
[options]
12-
experimental.const_params=true
1312

1413
[version]
1514
^0.61.0

src/error/GraphQLError.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export function GraphQLError( // eslint-disable-line no-redeclare
125125

126126
let _locations;
127127
if (positions && source) {
128-
_locations = positions.map(pos => getLocation(source, pos));
128+
const providedSource = source;
129+
_locations = positions.map(pos => getLocation(providedSource, pos));
129130
} else if (_nodes) {
130131
_locations = _nodes.reduce((list, node) => {
131132
if (node.loc) {

src/type/introspection.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import { GraphQLList, GraphQLNonNull } from '../type/wrappers';
2828
import { GraphQLString, GraphQLBoolean } from './scalars';
2929
import { DirectiveLocation } from '../language/directiveLocation';
30-
import type { GraphQLField, GraphQLType } from './definition';
30+
import type { GraphQLField } from './definition';
3131

3232
export const __Schema = new GraphQLObjectType({
3333
name: '__Schema',
@@ -465,11 +465,18 @@ export const introspectionTypes: $ReadOnlyArray<*> = [
465465
__TypeKind,
466466
];
467467

468-
export function isIntrospectionType(type: ?GraphQLType): boolean %checks {
468+
export function isIntrospectionType(type: mixed): boolean %checks {
469469
return (
470470
isNamedType(type) &&
471-
introspectionTypes.some(
472-
introspectionType => introspectionType.name === type.name,
473-
)
471+
// Would prefer to use introspectionTypes.some(), however %checks needs
472+
// a simple expression.
473+
(type.name === __Schema.name ||
474+
type.name === __Directive.name ||
475+
type.name === __DirectiveLocation.name ||
476+
type.name === __Type.name ||
477+
type.name === __Field.name ||
478+
type.name === __InputValue.name ||
479+
type.name === __EnumValue.name ||
480+
type.name === __TypeKind.name)
474481
);
475482
}

src/type/scalars.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import { GraphQLScalarType, isNamedType } from './definition';
1111
import * as Kind from '../language/kinds';
12-
import type { GraphQLType } from './definition';
1312

1413
// As per the GraphQL Spec, Integers are only treated as valid when a valid
1514
// 32-bit signed integer, providing the broadest support across platforms.
@@ -145,11 +144,15 @@ export const specifiedScalarTypes: $ReadOnlyArray<*> = [
145144
GraphQLID,
146145
];
147146

148-
export function isSpecifiedScalarType(type: ?GraphQLType): boolean %checks {
147+
export function isSpecifiedScalarType(type: mixed): boolean %checks {
149148
return (
150149
isNamedType(type) &&
151-
specifiedScalarTypes.some(
152-
specifiedScalarType => specifiedScalarType.name === type.name,
153-
)
150+
// Would prefer to use specifiedScalarTypes.some(), however %checks needs
151+
// a simple expression.
152+
(type.name === GraphQLString.name ||
153+
type.name === GraphQLInt.name ||
154+
type.name === GraphQLFloat.name ||
155+
type.name === GraphQLBoolean.name ||
156+
type.name === GraphQLID.name)
154157
);
155158
}

0 commit comments

Comments
 (0)