Skip to content

Commit fe5f544

Browse files
committed
Flow v0.47.0 finds 3 errors in master. This is important to fix, because the
graphql npm module ships with types, so anyone who uses the graphql npm module will get errors when upgrading to Flow v0.47.0. The new errors [look like this](https://gist.github.com/85d7f03510760dd223e968d2e92e7712). When investigating, I found that `typeFromAST()` was doing something a little odd. I believe it was trying to declare itself as an overloaded function, but instead it was declaring an overloaded function and then shadowing it with the exported function. When it's properly fixed, it exposes 26 errors, which is a little much for me to fix right now. So instead, I'm sabotaging its type completely.
1 parent 87b24ee commit fe5f544

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/utilities/typeFromAST.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ import type { GraphQLSchema } from '../type/schema';
2929
* found in the schema, then undefined will be returned.
3030
*/
3131
/* eslint-disable no-redeclare */
32-
declare function typeFromAST(
32+
declare function typeFromASTType(
3333
schema: GraphQLSchema,
3434
typeNode: NamedTypeNode
3535
): void | GraphQLNamedType;
36-
declare function typeFromAST(
36+
declare function typeFromASTType(
3737
schema: GraphQLSchema,
3838
typeNode: ListTypeNode
3939
): void | GraphQLList<*>;
40-
declare function typeFromAST(
40+
declare function typeFromASTType(
4141
schema: GraphQLSchema,
4242
typeNode: NonNullTypeNode
4343
): void | GraphQLNonNull<*>;
44-
export function typeFromAST(schema, typeNode) {
44+
function typeFromASTImpl(schema, typeNode) {
4545
/* eslint-enable no-redeclare */
4646
let innerType;
4747
if (typeNode.kind === LIST_TYPE) {
@@ -55,3 +55,7 @@ export function typeFromAST(schema, typeNode) {
5555
invariant(typeNode.kind === NAMED_TYPE, 'Must be a named type.');
5656
return schema.getType(typeNode.name.value);
5757
}
58+
// This will export typeFromAST with the correct type, but currently exposes
59+
// ~26 errors: https://gist.github.com/4a29403a99a8186fcb15064d69c5f3ae
60+
// export var typeFromAST: typeof typeFromASTType = typeFromASTImpl;
61+
export const typeFromAST: $FlowFixMe = typeFromASTImpl;

0 commit comments

Comments
 (0)