Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flow %checks to reduce occurance of :any #695

Merged
merged 1 commit into from Apr 29, 2017
Merged

Conversation

leebyron
Copy link
Contributor

This uses a pre-release flow feature to provide predicate functions with more type checking power. It also breaks apart some functions into multiple declare function statements for cases where more specific input types result in more specific output types.

@@ -134,11 +136,10 @@ export type GraphQLLeafType =
GraphQLScalarType |
GraphQLEnumType;

export function isLeafType(type: ?GraphQLType): boolean {
const namedType = getNamedType(type);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This was ambiguous before. Other isCompositeType / isAbstractType checks below do not include named type unwrapping, and it did not match the type definition above. Only one callsite actually relied on named type unwrapping, so moved this check there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled out into #697

@leebyron
Copy link
Contributor Author

I'm not super pleased about the eslint and babel workarounds required to get this all to work. I just wanted to get this up to show how it's useful. Perhaps we go after these tools to improve compatibility first?

}
},
FragmentDefinition(node) {
const type = context.getType();
const type = typeFromAST(context.getSchema(), node.typeCondition);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved all the changes in this file to #698

@leebyron
Copy link
Contributor Author

Might wait for babel/babylon#103 before landing this to avoid the flow comments.

@leebyron leebyron force-pushed the type-checks branch 3 times, most recently from d87eee2 to 8f01ff6 Compare January 27, 2017 23:09
@kassens
Copy link
Contributor

kassens commented Mar 29, 2017

@leebyron this could be merged now. (btw, no need for comments around %checks)

This uses a pre-release flow feature to provide predicate functions with more type checking power. It also breaks apart some functions into multiple declare function statements for cases where more specific input types result in more specific output types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants