From 1319b0be82827137f863deb16a1d4d4ce34f5a90 Mon Sep 17 00:00:00 2001 From: jdecroock Date: Fri, 22 Mar 2024 15:41:26 +0100 Subject: [PATCH] fix type --- src/__tests__/__snapshots__/parser.test.ts.snap | 3 +-- src/ast.ts | 3 +-- src/printer.ts | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/__tests__/__snapshots__/parser.test.ts.snap b/src/__tests__/__snapshots__/parser.test.ts.snap index 2db9d13..708f896 100644 --- a/src/__tests__/__snapshots__/parser.test.ts.snap +++ b/src/__tests__/__snapshots__/parser.test.ts.snap @@ -645,8 +645,7 @@ exports[`parse > parses the kitchen sink document like graphql.js does 1`] = ` "value": { "block": true, "kind": "StringValue", - "value": "block string uses """ -", + "value": "block string uses """", }, }, ], diff --git a/src/ast.ts b/src/ast.ts index 7da8460..4d97bb8 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -188,11 +188,10 @@ export type FragmentSpreadNode = Or< { readonly kind: Kind.FRAGMENT_SPREAD; readonly name: NameNode; - readonly arguments?: ReadonlyArray; readonly directives?: ReadonlyArray; readonly loc?: Location; } ->; +> & { readonly arguments?: ReadonlyArray }; export type InlineFragmentNode = Or< GraphQL.InlineFragmentNode, diff --git a/src/printer.ts b/src/printer.ts index 080f7bc..ec92b4f 100644 --- a/src/printer.ts +++ b/src/printer.ts @@ -97,7 +97,8 @@ const nodes: { }, FragmentSpread(node) { let out = '...' + node.name.value; - if (hasItems(node.arguments)) out += '(' + node.arguments.map(nodes.Argument!).join(', ') + ')'; + if ('arguments' in node && Array.isArray(node.arguments) && hasItems(node.arguments)) + out += '(' + node.arguments.map(nodes.Argument!).join(', ') + ')'; if (hasItems(node.directives)) out += ' ' + node.directives.map(nodes.Directive!).join(' '); return out; },