diff --git a/.changeset/loud-fishes-unite.md b/.changeset/loud-fishes-unite.md new file mode 100644 index 0000000..a3f73b8 --- /dev/null +++ b/.changeset/loud-fishes-unite.md @@ -0,0 +1,5 @@ +--- +"@graphql-ts/schema": patch +--- + +Add `const` to `Values` type parameter on `g.enum` to improve inference diff --git a/.gitignore b/.gitignore index 8b3b5c7..aa9c01f 100644 --- a/.gitignore +++ b/.gitignore @@ -103,4 +103,4 @@ dist # TernJS port file .tern-port -.vitepress/cache \ No newline at end of file +site/.vitepress/cache \ No newline at end of file diff --git a/packages/schema/src/output.ts b/packages/schema/src/output.ts index 411567a..0fde01a 100644 --- a/packages/schema/src/output.ts +++ b/packages/schema/src/output.ts @@ -603,7 +603,7 @@ export type GWithContext = { * `;) * ``` */ - enum: >( + enum: >( config: GEnumTypeConfig ) => GEnumType; /** diff --git a/test-project/index.test-d.ts b/test-project/index.test-d.ts index dffb419..17688d2 100644 --- a/test-project/index.test-d.ts +++ b/test-project/index.test-d.ts @@ -2162,3 +2162,21 @@ const someInputFields = { }, }); } + +{ + const x = g.enum({ + name: "X", + values: { + a: { + value: "a", + }, + b: { + value: "b", + }, + }, + }); + assertCompatible< + Invariant>, + Invariant + >(); +}