From 4091dcd33d38378cdc8f702a0ab1fa7b69cbb1cb Mon Sep 17 00:00:00 2001 From: KatieMSB Date: Fri, 28 Feb 2025 11:47:50 -0600 Subject: [PATCH 1/3] convert js files to typescript --- package.json | 2 +- web/src/app/util/LuxonLocalizer.js | 60 ------- web/src/app/util/LuxonLocalizer.ts | 100 +++++++++++ web/src/app/util/MountWatcher.js | 21 --- web/src/app/util/{graphql.js => graphql.ts} | 163 +++++++++++------- .../util/{promiseBatch.js => promiseBatch.ts} | 34 ++-- web/src/app/util/query_param.js | 27 --- web/src/app/util/query_param.ts | 6 + ...hrinkWorkaround.js => shrinkWorkaround.ts} | 4 +- yarn.lock | 10 +- 10 files changed, 232 insertions(+), 195 deletions(-) delete mode 100644 web/src/app/util/LuxonLocalizer.js create mode 100644 web/src/app/util/LuxonLocalizer.ts delete mode 100644 web/src/app/util/MountWatcher.js rename web/src/app/util/{graphql.js => graphql.ts} (58%) rename web/src/app/util/{promiseBatch.js => promiseBatch.ts} (59%) delete mode 100644 web/src/app/util/query_param.js create mode 100644 web/src/app/util/query_param.ts rename web/src/app/util/{shrinkWorkaround.js => shrinkWorkaround.ts} (77%) diff --git a/package.json b/package.json index af478875c7..6e1e3f5e53 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "@types/node": "22.10.5", "@types/prop-types": "15.7.14", "@types/react": "18.3.1", - "@types/react-big-calendar": "1.16.0", + "@types/react-big-calendar": "1.16.1", "@types/react-dom": "18.3.1", "@types/react-transition-group": "4.4.12", "@types/react-virtualized-auto-sizer": "1.0.4", diff --git a/web/src/app/util/LuxonLocalizer.js b/web/src/app/util/LuxonLocalizer.js deleted file mode 100644 index a5c6838a51..0000000000 --- a/web/src/app/util/LuxonLocalizer.js +++ /dev/null @@ -1,60 +0,0 @@ -import * as dates from 'react-big-calendar/lib/utils/dates' -import { DateLocalizer } from 'react-big-calendar/lib/localizer' - -const dateRangeFormat = ({ start, end }, culture, local) => - `${local.format(start, 'D', culture)} — ${local.format(end, 'D', culture)}` - -const timeRangeFormat = ({ start, end }, culture, local) => - `${local.format(start, 't', culture)} — ${local.format(end, 't', culture)}` - -const timeRangeStartFormat = ({ start }, culture, local) => - `${local.format(start, 't', culture)} — ` - -const timeRangeEndFormat = ({ end }, culture, local) => - ` — ${local.format(end, 't', culture)}` - -const weekRangeFormat = ({ start, end }, culture, local) => - `${local.format(start, 'MMMM dd', culture)} — ${local.format( - end, - dates.eq(start, end, 'month') ? 'dd' : 'MMMM dd', - culture, - )}` - -export const formats = { - dateFormat: 'dd', - dayFormat: 'dd EEE', - weekdayFormat: 'ccc', - - selectRangeFormat: timeRangeFormat, - eventTimeRangeFormat: timeRangeFormat, - eventTimeRangeStartFormat: timeRangeStartFormat, - eventTimeRangeEndFormat: timeRangeEndFormat, - - timeGutterFormat: 't', - - monthHeaderFormat: 'MMMM yyyy', - dayHeaderFormat: 'cccc MMM dd', - dayRangeHeaderFormat: weekRangeFormat, - agendaHeaderFormat: dateRangeFormat, - - agendaDateFormat: 'ccc MMM dd', - agendaTimeFormat: 't', - agendaTimeRangeFormat: timeRangeFormat, -} - -const LuxonLocalizer = function (DateTime, { firstDayOfWeek }) { - const locale = (d, c) => (c ? d.reconfigure(c) : d) - - return new DateLocalizer({ - formats, - firstOfWeek() { - return firstDayOfWeek - }, - - format(value, format, culture) { - return locale(DateTime.fromJSDate(value), culture).toFormat(format) - }, - }) -} - -export default LuxonLocalizer diff --git a/web/src/app/util/LuxonLocalizer.ts b/web/src/app/util/LuxonLocalizer.ts new file mode 100644 index 0000000000..211da70876 --- /dev/null +++ b/web/src/app/util/LuxonLocalizer.ts @@ -0,0 +1,100 @@ +import { + DateLocalizer, + DateRange, + DateRangeFormatFunction, + Formats, +} from 'react-big-calendar' +import { DateTime } from 'luxon' + +const isSameMonth = (range: DateRange): boolean => { + return ( + range.start.getFullYear() === range.end.getFullYear() && + range.start.getMonth() === range.end.getMonth() + ) +} + +const dateRangeFormat: DateRangeFormatFunction = ( + range, + culture, + localizer, +): string => + `${localizer?.format(range.start, 'D', culture)} — ${localizer?.format(range.end, 'D', culture)}` + +const timeRangeFormat: DateRangeFormatFunction = ( + range, + culture, + localizer, +): string => + `${localizer?.format(range.start, 't', culture)} — ${localizer?.format(range.end, 't', culture)}` + +const timeRangeStartFormat: DateRangeFormatFunction = ( + range, + culture, + localizer, +): string => `${localizer?.format(range.start, 't', culture)} — ` + +const timeRangeEndFormat: DateRangeFormatFunction = ( + range, + culture, + localizer, +): string => ` — ${localizer?.format(range.end, 't', culture)}` + +const weekRangeFormat: DateRangeFormatFunction = ( + range, + culture, + localizer, +): string => + `${localizer?.format(range.start, 'MMMM dd', culture)} — ${localizer?.format( + range.end, + isSameMonth(range) ? 'dd' : 'MMMM dd', + culture, + )}` + +export const formats: Formats = { + dateFormat: 'dd', + dayFormat: 'dd EEE', + weekdayFormat: 'ccc', + + selectRangeFormat: timeRangeFormat, + eventTimeRangeFormat: timeRangeFormat, + eventTimeRangeStartFormat: timeRangeStartFormat, + eventTimeRangeEndFormat: timeRangeEndFormat, + + timeGutterFormat: 't', + + monthHeaderFormat: 'MMMM yyyy', + dayHeaderFormat: 'cccc MMM dd', + dayRangeHeaderFormat: weekRangeFormat, + agendaHeaderFormat: dateRangeFormat, + + agendaDateFormat: 'ccc MMM dd', + agendaTimeFormat: 't', + agendaTimeRangeFormat: timeRangeFormat, +} + +interface LuxonLocalizerOptions { + firstDayOfWeek: number +} + +const LuxonLocalizer = ( + DateTime: typeof import('luxon').DateTime, + { firstDayOfWeek }: LuxonLocalizerOptions, +): DateLocalizer => { + const locale = (d: DateTime, c?: string): DateTime => + c ? d.reconfigure({ locale: c }) : d + + return new DateLocalizer({ + formats, + firstOfWeek() { + return firstDayOfWeek + }, + + format(value, format, culture) { + return locale(DateTime.fromJSDate(value as Date), culture).toFormat( + format, + ) + }, + }) +} + +export default LuxonLocalizer diff --git a/web/src/app/util/MountWatcher.js b/web/src/app/util/MountWatcher.js deleted file mode 100644 index 67ee5878ca..0000000000 --- a/web/src/app/util/MountWatcher.js +++ /dev/null @@ -1,21 +0,0 @@ -import { useEffect } from 'react' -import p from 'prop-types' - -export default function MountWatcher(props) { - useEffect(() => { - props.onMount() - return () => props.onUnmount() - }, []) - - return props.children -} - -MountWatcher.propTypes = { - onMount: p.func, - onUnmount: p.func, -} - -MountWatcher.defaultProps = { - onMount: () => {}, - onUnmount: () => {}, -} diff --git a/web/src/app/util/graphql.js b/web/src/app/util/graphql.ts similarity index 58% rename from web/src/app/util/graphql.js rename to web/src/app/util/graphql.ts index 7244aacdf6..55be33e157 100644 --- a/web/src/app/util/graphql.js +++ b/web/src/app/util/graphql.ts @@ -1,3 +1,14 @@ +import { + DocumentNode, + FieldNode, + DefinitionNode, + Kind, + NameNode, + OperationDefinitionNode, + SelectionNode, + VariableDefinitionNode, +} from 'graphql' + /** * queryByName returns a new GraphQL document with a single query from the provided doc. * @@ -23,8 +34,10 @@ * ``` * */ -export function queryByName(doc, name) { - const def = doc.definitions.find((def) => def.name.value === name) +export function queryByName(doc: DocumentNode, name: string): DocumentNode { + const def = doc.definitions.find( + (def) => 'name' in def && def.name?.value === name, + ) if (!def) throw new Error('no definition found for ' + name) return { ...doc, @@ -58,19 +71,19 @@ export function queryByName(doc, name) { * } * ` */ -export function fieldAlias(doc, aliasName) { +export function fieldAlias(doc: DocumentNode, aliasName: string): DocumentNode { if (doc.definitions.length > 1) { throw new Error( `found ${doc.definitions.length} query definitions, but expected 1`, ) } - const def = doc.definitions[0] + const def = doc.definitions[0] as OperationDefinitionNode if (def.selectionSet.selections.length > 1) { throw new Error( `found ${def.selectionSet.selections.length} fields, but expected 1`, ) } - const sel = def.selectionSet.selections[0] + const sel = def.selectionSet.selections[0] as SelectionNode return { ...doc, @@ -82,8 +95,11 @@ export function fieldAlias(doc, aliasName) { selections: [ { ...sel, - alias: { kind: 'Name', value: aliasName }, - }, + alias: { + kind: 'Name' as Kind.NAME, + value: aliasName, + }, + } as FieldNode, ], }, }, @@ -112,13 +128,14 @@ export function fieldAlias(doc, aliasName) { * } * ` */ -export function prefixQuery(doc, prefix) { - const mapVarName = (name) => ({ +export function prefixQuery(doc: DocumentNode, prefix: string): DocumentNode { + const mapVarName = (name: { value: string }): NameNode => ({ ...name, value: prefix + name.value, + kind: Kind.NAME, }) - const mapSelName = (sel) => { - if (sel.alias) { + const mapSelName = (sel: FieldNode): FieldNode => { + if ('alias' in sel && sel.alias) { return { ...sel, alias: { @@ -131,39 +148,41 @@ export function prefixQuery(doc, prefix) { return { ...sel, alias: { - kind: 'Name', + kind: 'Name' as Kind.NAME, value: prefix + sel.name.value, }, } } return { ...doc, - definitions: doc.definitions.map((def) => ({ - ...def, - variableDefinitions: def.variableDefinitions.map((vDef) => ({ - ...vDef, - variable: { - ...vDef.variable, - name: mapVarName(vDef.variable.name), - }, - })), - selectionSet: { - ...def.selectionSet, - selections: def.selectionSet.selections.map((sel) => ({ - ...mapSelName(sel), - arguments: sel.arguments.map((arg) => ({ - ...arg, - value: - arg.value.kind !== 'Variable' - ? arg.value - : { - ...arg.value, - name: mapVarName(arg.value.name), - }, + definitions: doc.definitions.map((def) => { + if (def.kind !== 'OperationDefinition') return def + return { + ...def, + variableDefinitions: def.variableDefinitions?.map( + (vDef: VariableDefinitionNode) => ({ + ...vDef, + variable: { + ...vDef.variable, + name: mapVarName(vDef.variable.name), + }, + }), + ), + selectionSet: { + ...def.selectionSet, + selections: def.selectionSet.selections.map((sel: SelectionNode) => ({ + ...mapSelName(sel as FieldNode), + arguments: (sel as FieldNode).arguments?.map((arg) => ({ + ...arg, + value: + arg.value.kind !== 'Variable' + ? arg.value + : { ...arg.value, name: mapVarName(arg.value.name) }, + })), })), - })), - }, - })), + }, + } as DefinitionNode + }), } } @@ -187,39 +206,46 @@ export function prefixQuery(doc, prefix) { * } * ` */ -export function mapInputVars(doc, mapVars = {}) { - const mapName = (name) => ({ +export function mapInputVars( + doc: DocumentNode, + mapVars: Record = {}, +): DocumentNode { + const mapName = (name: { value: string }): NameNode => ({ ...name, value: mapVars[name.value] || name.value, + kind: Kind.NAME, }) + return { ...doc, - definitions: doc.definitions.map((def) => ({ - ...def, - variableDefinitions: def.variableDefinitions.map((vDef) => ({ - ...vDef, - variable: { - ...vDef.variable, - name: mapName(vDef.variable.name), - }, - })), - selectionSet: { - ...def.selectionSet, - selections: def.selectionSet.selections.map((sel) => ({ - ...sel, - arguments: sel.arguments.map((arg) => ({ - ...arg, - value: - arg.value.kind !== 'Variable' - ? arg.value - : { - ...arg.value, - name: mapName(arg.value.name), - }, + definitions: doc.definitions.map((def) => { + if (def.kind !== 'OperationDefinition') return def + return { + ...def, + variableDefinitions: def.variableDefinitions?.map( + (vDef: VariableDefinitionNode) => ({ + ...vDef, + variable: { + ...vDef.variable, + name: mapName(vDef.variable.name), + }, + }), + ), + selectionSet: { + ...def.selectionSet, + selections: def.selectionSet.selections.map((sel: SelectionNode) => ({ + ...sel, + arguments: (sel as FieldNode).arguments?.map((arg) => ({ + ...arg, + value: + arg.value.kind !== 'Variable' + ? arg.value + : { ...arg.value, name: mapName(arg.value.name) }, + })), })), - })), - }, - })), + }, + } as DefinitionNode + }), } } @@ -248,7 +274,10 @@ export function mapInputVars(doc, mapVars = {}) { * } * ` */ -export function mergeFields(doc, newQuery) { +export function mergeFields( + doc: DocumentNode, + newQuery: DocumentNode, +): DocumentNode { if (!doc) return newQuery if (doc.definitions.length > 1) { throw new Error( @@ -261,8 +290,8 @@ export function mergeFields(doc, newQuery) { ) } - const def = doc.definitions[0] - const newDef = newQuery.definitions[0] + const def = doc.definitions[0] as OperationDefinitionNode + const newDef = newQuery.definitions[0] as OperationDefinitionNode return { ...doc, definitions: [ diff --git a/web/src/app/util/promiseBatch.js b/web/src/app/util/promiseBatch.ts similarity index 59% rename from web/src/app/util/promiseBatch.js rename to web/src/app/util/promiseBatch.ts index c2e66f47d0..0dd1c69ea6 100644 --- a/web/src/app/util/promiseBatch.js +++ b/web/src/app/util/promiseBatch.ts @@ -1,16 +1,16 @@ import { BATCH_DELAY } from '../config' -function _finally(p, fn) { +function _finally(p: Promise, fn: () => void): Promise { if (p.finally) return p.finally(fn) // fallback to manual implementation return p.then( (val) => { - const v = () => val + const v = (): T => val return Promise.resolve().then(fn).then(v) }, (err) => { - const e = () => Promise.reject(err) + const e = (): Promise => Promise.reject(err) return Promise.resolve().then(fn).then(e) }, ) @@ -20,33 +20,41 @@ function _finally(p, fn) { // It differs from Promise.all and Promise.allSettled in that you can add // additional promises after creation. class BatchPromise { - _p = new Promise((resolve) => { - this._resolveP = resolve - }) + private _p: Promise + private _resolveP!: () => void + private _unresolvedCount = 1 // start with +1 for the timer - _unresolvedCount = 1 // start with +1 for the timer + constructor() { + this._p = new Promise((resolve) => { + this._resolveP = resolve + }) + } - resolveOne = () => { + resolveOne = (): Promise => { this._unresolvedCount-- if (this._unresolvedCount === 0) this._resolveP() return this._p } - addPromise = (p) => { + addPromise(p: Promise): Promise { this._unresolvedCount++ return _finally(p, this.resolveOne) } } -let currentBatch, t -function batchReset() { - currentBatch.resolveOne() +let currentBatch: BatchPromise | null = null +let t: NodeJS.Timeout +function batchReset(): void { + currentBatch?.resolveOne() currentBatch = null } // promiseBatch will return a new Promise that will resolve after all Promises // that were provided during the debounce (ms) delay. -export default function promiseBatch(p, debounce = BATCH_DELAY) { +export default function promiseBatch( + p: Promise, + debounce: number = BATCH_DELAY, +): Promise { if (!currentBatch) { currentBatch = new BatchPromise() } diff --git a/web/src/app/util/query_param.js b/web/src/app/util/query_param.js deleted file mode 100644 index eca60dcebd..0000000000 --- a/web/src/app/util/query_param.js +++ /dev/null @@ -1,27 +0,0 @@ -export function getParameterByName(name, url = global.location.href) { - return new URL(url).searchParams.get(name) -} - -// returns hash of all parameters with keys and values -export function getAllParameters(url = global.location.href) { - const q = {} - for (const [key, value] of new URL(url).searchParams) { - q[key] = value - } - - return q -} - -// takes in a var name, var value, and optionally a url to read previous params from. -// returns a string of the params and the maintained hash (DOES NOT RETURN THE PATH) -export function setParameterByName(name, value, url = global.location.href) { - const u = new URL(url) - u.searchParams.set(name, value) - return u.toString() -} - -// clears the parameter given from the current url -export function clearParameter(name, url = global.location.href) { - const query = setParameterByName(name, null, url) - return query -} diff --git a/web/src/app/util/query_param.ts b/web/src/app/util/query_param.ts new file mode 100644 index 0000000000..5479879fac --- /dev/null +++ b/web/src/app/util/query_param.ts @@ -0,0 +1,6 @@ +export function getParameterByName( + name: string, + url: string = global.location.href, +): string | null { + return new URL(url).searchParams.get(name) +} diff --git a/web/src/app/util/shrinkWorkaround.js b/web/src/app/util/shrinkWorkaround.ts similarity index 77% rename from web/src/app/util/shrinkWorkaround.js rename to web/src/app/util/shrinkWorkaround.ts index 1f5ef79581..d1f5a08862 100644 --- a/web/src/app/util/shrinkWorkaround.js +++ b/web/src/app/util/shrinkWorkaround.ts @@ -8,7 +8,9 @@ import _ from 'lodash' // ...otherInputProps, // ...shrinkWorkaround(value) // } -export default function shrinkWorkaround(value) { +export default function shrinkWorkaround(value: string | number): { + shrink?: boolean +} { if (_.isEmpty(value) && !_.isNumber(value)) return {} return { shrink: true } } diff --git a/yarn.lock b/yarn.lock index 33793823c4..90d0376653 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6538,14 +6538,14 @@ __metadata: languageName: node linkType: hard -"@types/react-big-calendar@npm:1.16.0": - version: 1.16.0 - resolution: "@types/react-big-calendar@npm:1.16.0" +"@types/react-big-calendar@npm:1.16.1": + version: 1.16.1 + resolution: "@types/react-big-calendar@npm:1.16.1" dependencies: "@types/date-arithmetic": "npm:*" "@types/prop-types": "npm:*" "@types/react": "npm:*" - checksum: 10/b71d0f2b199292bd269e5656d50b926aa94337b2a36f77f835c929d93f95c9e749284d1b2826198531319e47f86960c0a80ac5a8890f99398b32dec92d948719 + checksum: 10/eb881d68dfa7027f6f714bde730952713f07fae4de3edd77a38f9c863e30525f694d30b6140a829511c72948c01eacc23357dcdb54d09095d691373d0128b588 languageName: node linkType: hard @@ -18180,7 +18180,7 @@ __metadata: "@types/node": "npm:22.10.5" "@types/prop-types": "npm:15.7.14" "@types/react": "npm:18.3.1" - "@types/react-big-calendar": "npm:1.16.0" + "@types/react-big-calendar": "npm:1.16.1" "@types/react-dom": "npm:18.3.1" "@types/react-transition-group": "npm:4.4.12" "@types/react-virtualized-auto-sizer": "npm:1.0.4" From 4c99517f1e9067317671920aff72862d1a9ba156 Mon Sep 17 00:00:00 2001 From: KatieMSB Date: Fri, 28 Feb 2025 12:21:21 -0600 Subject: [PATCH 2/3] convert graphql.test.js to typescript --- .../app/util/{graphql.test.js => graphql.test.ts} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename web/src/app/util/{graphql.test.js => graphql.test.ts} (87%) diff --git a/web/src/app/util/graphql.test.js b/web/src/app/util/graphql.test.ts similarity index 87% rename from web/src/app/util/graphql.test.js rename to web/src/app/util/graphql.test.ts index 795651e2f0..239f470995 100644 --- a/web/src/app/util/graphql.test.js +++ b/web/src/app/util/graphql.test.ts @@ -1,5 +1,5 @@ import { gql } from 'urql' -import { print } from 'graphql' +import { DocumentNode, print } from 'graphql' import { queryByName, @@ -9,7 +9,7 @@ import { prefixQuery, } from './graphql' -const expectEqual = (a, b) => expect(print(a)).toBe(print(b)) +const expectEqual = (a: DocumentNode, b: DocumentNode) => expect(print(a)).toBe(print(b)) describe('queryByName', () => { it('should fetch a single query', () => { @@ -32,7 +32,7 @@ describe('queryByName', () => { }) describe('fieldAlias', () => { - const check = (name, arg, query, expected) => + const check = (name: string, arg: string, query: DocumentNode, expected: DocumentNode) => test(name, () => expect(print(fieldAlias(query, arg))).toBe(print(expected)), ) @@ -77,14 +77,14 @@ describe('fieldAlias', () => { }) describe('prefixQuery', () => { - const check = (name, arg, query, expected) => + const check = (name: string, arg: string, query: DocumentNode, expected: DocumentNode) => test(name, () => expect(print(prefixQuery(query, 'q0_'))).toBe(print(expected)), ) check( 'should prefix query and variables', - {}, + '', gql` query ($id: ID!, $id2: ID!) { user(id: $id) { @@ -113,7 +113,7 @@ describe('prefixQuery', () => { }) describe('mapInputVars', () => { - const check = (name, arg, query, expected) => + const check = (name: string, arg: Record, query: DocumentNode, expected: DocumentNode) => test(name, () => expect(print(mapInputVars(query, arg))).toBe(print(expected)), ) @@ -183,7 +183,7 @@ describe('mapInputVars', () => { }) describe('mergeFields', () => { - const check = (name, query1, query2, expected) => + const check = (name: string, query1: DocumentNode, query2: DocumentNode, expected: DocumentNode) => test(name, () => expect(print(mergeFields(query1, query2))).toBe(print(expected)), ) From 2a5edcd6cdbe62fc4051059277b2dbeba329223a Mon Sep 17 00:00:00 2001 From: KatieMSB Date: Fri, 28 Feb 2025 13:59:09 -0600 Subject: [PATCH 3/3] update graphql.test formatting --- web/src/app/util/graphql.test.ts | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/web/src/app/util/graphql.test.ts b/web/src/app/util/graphql.test.ts index 239f470995..7dd5d30de2 100644 --- a/web/src/app/util/graphql.test.ts +++ b/web/src/app/util/graphql.test.ts @@ -9,7 +9,8 @@ import { prefixQuery, } from './graphql' -const expectEqual = (a: DocumentNode, b: DocumentNode) => expect(print(a)).toBe(print(b)) +const expectEqual = (a: DocumentNode, b: DocumentNode): void => + expect(print(a)).toBe(print(b)) describe('queryByName', () => { it('should fetch a single query', () => { @@ -32,7 +33,12 @@ describe('queryByName', () => { }) describe('fieldAlias', () => { - const check = (name: string, arg: string, query: DocumentNode, expected: DocumentNode) => + const check = ( + name: string, + arg: string, + query: DocumentNode, + expected: DocumentNode, + ): void => test(name, () => expect(print(fieldAlias(query, arg))).toBe(print(expected)), ) @@ -77,7 +83,12 @@ describe('fieldAlias', () => { }) describe('prefixQuery', () => { - const check = (name: string, arg: string, query: DocumentNode, expected: DocumentNode) => + const check = ( + name: string, + arg: string, + query: DocumentNode, + expected: DocumentNode, + ): void => test(name, () => expect(print(prefixQuery(query, 'q0_'))).toBe(print(expected)), ) @@ -113,7 +124,12 @@ describe('prefixQuery', () => { }) describe('mapInputVars', () => { - const check = (name: string, arg: Record, query: DocumentNode, expected: DocumentNode) => + const check = ( + name: string, + arg: Record, + query: DocumentNode, + expected: DocumentNode, + ): void => test(name, () => expect(print(mapInputVars(query, arg))).toBe(print(expected)), ) @@ -183,7 +199,12 @@ describe('mapInputVars', () => { }) describe('mergeFields', () => { - const check = (name: string, query1: DocumentNode, query2: DocumentNode, expected: DocumentNode) => + const check = ( + name: string, + query1: DocumentNode, + query2: DocumentNode, + expected: DocumentNode, + ): void => test(name, () => expect(print(mergeFields(query1, query2))).toBe(print(expected)), )