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

Enable "sketchy-null-mixed" Flow check #1880

Merged
merged 1 commit into from May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flowconfig
Expand Up @@ -13,7 +13,7 @@
sketchy-null-bool=off
sketchy-null-string=off
sketchy-null-number=error
sketchy-null-mixed=off
sketchy-null-mixed=error
sketchy-number=error
untyped-type-import=error
nonstrict-import=off
Expand Down
8 changes: 7 additions & 1 deletion src/error/GraphQLError.js
Expand Up @@ -138,7 +138,13 @@ export function GraphQLError( // eslint-disable-line no-redeclare
}, []);
}

const _extensions = extensions || (originalError && originalError.extensions);
let _extensions = extensions;
if (_extensions == null && originalError != null) {
const originalExtensions = originalError.extensions;
if (originalExtensions != null && typeof originalExtensions === 'object') {
_extensions = originalExtensions;
}
}

Object.defineProperties(this, {
message: {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/inspect.js
Expand Up @@ -41,7 +41,7 @@ function formatObjectValue(value, previouslySeenValues) {
if (value) {
const customInspectFn = getCustomFn(value);

if (customInspectFn) {
if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
const customValue = customInspectFn.call(value);

Expand Down
3 changes: 2 additions & 1 deletion src/jsutils/invariant.js
Expand Up @@ -8,8 +8,9 @@
*/

export default function invariant(condition: mixed, message: string) {
const booleanCondition = Boolean(condition);
/* istanbul ignore else */
if (!condition) {
if (!booleanCondition) {
throw new Error(message);
}
}
2 changes: 1 addition & 1 deletion src/language/__tests__/toJSONDeep.js
Expand Up @@ -12,7 +12,7 @@
* on any nested value which defines it.
*/
export default function toJSONDeep<T>(value: T): T {
if (!value || typeof value !== 'object') {
if (value == null || typeof value !== 'object') {
return value;
}

Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/visitor-test.js
Expand Up @@ -472,7 +472,7 @@ describe('Visitor', () => {
'enter',
node.kind,
key,
parent && parent.kind ? parent.kind : undefined,
parent && parent.kind != null ? parent.kind : undefined,
]);

checkVisitorFnArgs(ast, arguments);
Expand All @@ -484,7 +484,7 @@ describe('Visitor', () => {
'leave',
node.kind,
key,
parent && parent.kind ? parent.kind : undefined,
parent && parent.kind != null ? parent.kind : undefined,
]);

expect(argsStack.pop()).to.deep.equal([...arguments]);
Expand Down