From 906818c0468a2938d2d86f84c3f7f0ab428899f2 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Fri, 10 Jul 2026 09:58:06 +0200 Subject: [PATCH] fix: widen DocumentNode tokenCount type --- .changeset/tidy-bags-fix.md | 5 +++++ src/ast.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/tidy-bags-fix.md diff --git a/.changeset/tidy-bags-fix.md b/.changeset/tidy-bags-fix.md new file mode 100644 index 0000000..62c93d3 --- /dev/null +++ b/.changeset/tidy-bags-fix.md @@ -0,0 +1,5 @@ +--- +'@0no-co/graphql.web': patch +--- + +Allow `undefined` on `DocumentNode.tokenCount` to preserve compatibility with `graphql` when `exactOptionalPropertyTypes` is enabled. diff --git a/src/ast.ts b/src/ast.ts index c04df5a..817cada 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -99,12 +99,12 @@ export type NameNode = Or< >; export type DocumentNode = Or< - GraphQL.DocumentNode & { readonly tokenCount?: number }, + GraphQL.DocumentNode & { readonly tokenCount?: number | undefined }, { readonly kind: Kind.DOCUMENT; readonly definitions: ReadonlyArray; readonly loc?: Location; - readonly tokenCount?: number; + readonly tokenCount?: number | undefined; } >;