From 616a2ab36c2a50e4855d15a5a9cf0ce88cfb929d Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Thu, 11 Jan 2024 01:25:04 +0000 Subject: [PATCH] Add fallback to `unknown` for missing selection sets --- src/__tests__/selection.test-d.ts | 11 +++++++++++ src/selection.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/__tests__/selection.test-d.ts b/src/__tests__/selection.test-d.ts index d017dd70..85780da6 100644 --- a/src/__tests__/selection.test-d.ts +++ b/src/__tests__/selection.test-d.ts @@ -36,6 +36,17 @@ test('infers unknown fields as `unknown`', () => { expectTypeOf().toEqualTypeOf(); }); +test('infers object fields with missing selection set as `unknown`', () => { + type query = parseDocument; + + type actual = getDocumentType; + type expected = { latestTodo: unknown }; + + expectTypeOf().toEqualTypeOf(); +}); + test('infers adjacent inline fragments', () => { type query = parseDocument - : {} + : unknown : Introspection['types'][Type['name']]['type'] : unknown;