Skip to content

Commit

Permalink
Update Flow (graphql#2754)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Aug 24, 2020
1 parent 94dc334 commit dd52a15
Show file tree
Hide file tree
Showing 43 changed files with 156 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ experimental.const_params=true
include_warnings=true

[version]
^0.131.0
^0.132.0
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules",
"eslint-plugin-istanbul": "0.1.2",
"eslint-plugin-node": "11.1.0",
"flow-bin": "0.131.0",
"flow-bin": "0.132.0",
"mocha": "8.1.1",
"nyc": "15.1.0",
"prettier": "2.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class GraphQLError extends Error {
}

// FIXME: workaround to not break chai comparisons, should be remove in v16
// $FlowFixMe Flow doesn't support computed properties yet
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG](): string {
return 'Object';
}
Expand Down
6 changes: 3 additions & 3 deletions src/error/__tests__/formatError-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphQLError } from '../GraphQLError';

describe('formatError: default error formatter', () => {
it('uses default message', () => {
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
const e = new GraphQLError();

expect(formatError(e)).to.deep.equal({
Expand Down Expand Up @@ -45,12 +45,12 @@ describe('formatError: default error formatter', () => {
});

it('rejects null and undefined errors', () => {
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => formatError(undefined)).to.throw(
'Received null or undefined error.',
);

// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => formatError(null)).to.throw(
'Received null or undefined error.',
);
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/abstract-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ describe('Execute: Handles execution of abstract types', () => {
const fooInterface = new GraphQLInterfaceType({
name: 'FooInterface',
fields: { bar: { type: GraphQLString } },
// $FlowExpectedError
resolveType() {
// $FlowExpectedError[incompatible-call]
return [];
},
});
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ describe('Execute: Handles basic execution tasks', () => {
}),
});

// $FlowExpectedError
// $FlowExpectedError[prop-missing]
expect(() => executeSync({ schema })).to.throw('Must provide document.');
});

it('throws if no schema is provided', () => {
const document = parse('{ field }');

// $FlowExpectedError
// $FlowExpectedError[prop-missing]
expect(() => executeSync({ document })).to.throw(
'Expected undefined to be a GraphQL schema.',
);
Expand All @@ -63,7 +63,7 @@ describe('Execute: Handles basic execution tasks', () => {
`);
const variableValues = '{ "a": 1 }';

// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => executeSync({ schema, document, variableValues })).to.throw(
'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.',
);
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function formatObjectValue(value, previouslySeenValues) {
const customInspectFn = getCustomFn(value);

if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
// $FlowFixMe[incompatible-use]
const customValue = customInspectFn.call(value);

// check for infinite recursion
Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ function expectSyntaxError(text) {

describe('Parser', () => {
it('asserts that a source to parse was provided', () => {
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => parse()).to.throw('Must provide Source. Received: undefined.');
});

it('asserts that an invalid source to parse was provided', () => {
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => parse({})).to.throw('Must provide Source. Received: {}.');
});

Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Printer: Query document', () => {
it('produces helpful error messages', () => {
const badAST = { random: 'Data' };

// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => print(badAST)).to.throw(
'Invalid AST Node: { random: "Data" }.',
);
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Printer: Query document', () => {
const printed = print(parse(kitchenSinkQuery));

expect(printed).to.equal(
// $FlowFixMe
// $FlowFixMe[incompatible-call]
dedent(String.raw`
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
whoever123is: node(id: [123, 456]) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/schema-printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Printer: SDL document', () => {
it('produces helpful error messages', () => {
const badAST = { random: 'Data' };

// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(() => print(badAST)).to.throw(
'Invalid AST Node: { random: "Data" }.',
);
Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/toJSONDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function toJSONDeep(value: mixed): mixed {
}

if (typeof value.toJSON === 'function') {
// $FlowFixMe(>=0.90.0)
// $FlowFixMe[incompatible-use]
return value.toJSON();
}

Expand Down
2 changes: 1 addition & 1 deletion src/language/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Source {
);
}

// $FlowFixMe Flow doesn't support computed properties yet
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
return 'Source';
}
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/arrayFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare function arrayFrom<T: mixed>(
): Array<T>;

/* eslint-disable no-redeclare */
// $FlowFixMe
// $FlowFixMe[name-already-bound]
const arrayFrom =
Array.from ||
function (obj, mapFn, thisArg) {
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare function find<T>(
): T | void;

/* eslint-disable no-redeclare */
// $FlowFixMe
// $FlowFixMe[name-already-bound]
const find = Array.prototype.find
? function (list, predicate) {
return Array.prototype.find.call(list, predicate);
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/flatMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare function flatMap<T, U>(
const flatMapMethod = Array.prototype.flatMap;

/* eslint-disable no-redeclare */
// $FlowFixMe
// $FlowFixMe[name-already-bound]
const flatMap = flatMapMethod
? function (list, fn) {
return flatMapMethod.call(list, fn);
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/isFinite.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare function isFinitePolyfill(
): boolean %checks(typeof value === 'number');

/* eslint-disable no-redeclare */
// $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
const isFinitePolyfill =
Number.isFinite ||
function (value) {
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/isInteger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ declare function isInteger(value: mixed): boolean %checks(typeof value ===
'number');

/* eslint-disable no-redeclare */
// $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
const isInteger =
Number.isInteger ||
function (value) {
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/objectEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ObjMap } from '../jsutils/ObjMap';
declare function objectEntries<T>(obj: ObjMap<T>): Array<[string, T]>;

/* eslint-disable no-redeclare */
// $FlowFixMe workaround for: https://github.com/facebook/flow/issues/5838
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
const objectEntries =
Object.entries || ((obj) => Object.keys(obj).map((key) => [key, obj[key]]));

Expand Down
2 changes: 1 addition & 1 deletion src/polyfills/objectValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ObjMap } from '../jsutils/ObjMap';
declare function objectValues<T>(obj: ObjMap<T>): Array<T>;

/* eslint-disable no-redeclare */
// $FlowFixMe workaround for: https://github.com/facebook/flow/issues/2221
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
const objectValues =
Object.values || ((obj) => Object.keys(obj).map((key) => obj[key]));
export default objectValues;
4 changes: 2 additions & 2 deletions src/polyfills/symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const SYMBOL_ITERATOR: string =
// In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
export const SYMBOL_ASYNC_ITERATOR: string =
// $FlowFixMe Flow doesn't define `Symbol.asyncIterator` yet
// $FlowFixMe[prop-missing] Flow doesn't define `Symbol.asyncIterator` yet
typeof Symbol === 'function' ? Symbol.asyncIterator : '@@asyncIterator';

// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
export const SYMBOL_TO_STRING_TAG: string =
// $FlowFixMe Flow doesn't define `Symbol.toStringTag` yet
// $FlowFixMe[incompatible-type] Flow doesn't define `Symbol.toStringTag` yet
typeof Symbol === 'function' ? Symbol.toStringTag : '@@toStringTag';
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('eventEmitterAsyncIterator', () => {
const i5 = iterator.next().then((x) => x);

// Terminate emitter
// $FlowFixMe
// $FlowFixMe[prop-missing]
await iterator.return();

// Publish is not caught after terminate
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/__tests__/eventEmitterAsyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function eventEmitterAsyncIterator(
emptyQueue();
return Promise.reject(error);
},
// $FlowFixMe Blocked by https://github.com/facebook/flow/issues/3258
// $FlowFixMe[prop-missing] Blocked by https://github.com/facebook/flow/issues/3258
[Symbol.asyncIterator]() {
return this;
},
Expand Down
6 changes: 3 additions & 3 deletions src/subscription/__tests__/mapAsyncIterator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('mapAsyncIterator', () => {
const items = [1, 2, 3];

const iterator: any = {
// $FlowFixMe Blocked by https://github.com/facebook/flow/issues/3258
// $FlowFixMe[prop-missing] Blocked by https://github.com/facebook/flow/issues/3258
[Symbol.asyncIterator]() {
return this;
},
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('mapAsyncIterator', () => {
const items = [1, 2, 3];

const iterator: any = {
// $FlowFixMe Blocked by https://github.com/facebook/flow/issues/3258
// $FlowFixMe[prop-missing] Blocked by https://github.com/facebook/flow/issues/3258
[Symbol.asyncIterator]() {
return this;
},
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('mapAsyncIterator', () => {
const items = [1, 2, 3];

const iterator: any = {
// $FlowFixMe Blocked by https://github.com/facebook/flow/issues/3258
// $FlowFixMe[prop-missing] Blocked by https://github.com/facebook/flow/issues/3258
[Symbol.asyncIterator]() {
return this;
},
Expand Down
26 changes: 13 additions & 13 deletions src/subscription/__tests__/subscribe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function createSubscription(
// `subscribe` returns Promise<AsyncIterator | ExecutionResult>
return {
sendImportantEmail,
// $FlowFixMe
// $FlowFixMe[incompatible-call]
subscription: await subscribe({ schema, document, rootValue: data }),
};
}
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('Subscription Initialization Phase', () => {
// Empty
}

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const ai = await subscribe(emailSchema, document, {
importantEmail: emptyAsyncIterator,
});
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('Subscription Initialization Phase', () => {
}),
});

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema,
document: parse(`
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('Subscription Initialization Phase', () => {
}),
});

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema,
document: parse(`
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('Subscription Initialization Phase', () => {
subscription: SubscriptionTypeMultiple,
});

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema,
document: parse(`
Expand Down Expand Up @@ -320,27 +320,27 @@ describe('Subscription Initialization Phase', () => {
`);

await expectPromiseToThrow(
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
() => subscribe({ schema: null, document }),
'Expected null to be a GraphQL schema.',
);

await expectPromiseToThrow(
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
() => subscribe({ document }),
'Expected undefined to be a GraphQL schema.',
);
});

it('throws an error if document is missing', async () => {
await expectPromiseToThrow(
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
() => subscribe({ schema: emailSchema, document: null }),
'Must provide document.',
);

await expectPromiseToThrow(
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
() => subscribe({ schema: emailSchema }),
'Must provide document.',
);
Expand Down Expand Up @@ -370,7 +370,7 @@ describe('Subscription Initialization Phase', () => {
it('should pass through unexpected errors thrown in subscribe', async () => {
let expectedError;
try {
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
await subscribe({ schema: emailSchema, document: {} });
} catch (error) {
expectedError = error;
Expand Down Expand Up @@ -930,7 +930,7 @@ describe('Subscription Publish Phase', () => {
},
);

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand Down Expand Up @@ -1002,7 +1002,7 @@ describe('Subscription Publish Phase', () => {
(email) => email,
);

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand Down Expand Up @@ -1056,7 +1056,7 @@ describe('Subscription Publish Phase', () => {
(email) => email,
);

// $FlowFixMe
// $FlowFixMe[incompatible-call]
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand Down
Loading

0 comments on commit dd52a15

Please sign in to comment.