Skip to content

Commit bfe3c75

Browse files
feat: support erasableSyntaxOnly (#10307)
Update the generated `TypedDocumentString` class to remove the usage of class parameters in order to be compatible with `erasableSyntaxOnly`
1 parent bd5772a commit bfe3c75

File tree

7 files changed

+51
-9
lines changed

7 files changed

+51
-9
lines changed

.changeset/unlucky-pumpkins-build.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-codegen/typed-document-node': minor
3+
'@graphql-codegen/client-preset': minor
4+
---
5+
6+
Update generated code to be compatible with TypeScript 5.8 `erasableSyntaxOnly` flag

examples/persisted-documents-string-mode/src/gql/graphql.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ export class TypedDocumentString<TResult, TVariables>
3939
implements DocumentTypeDecoration<TResult, TVariables>
4040
{
4141
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
42+
private value: string;
43+
public __meta__?: Record<string, any> | undefined;
4244

43-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
45+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
4446
super(value);
47+
this.value = value;
48+
this.__meta__ = __meta__;
4549
}
4650

4751
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

examples/react/tanstack-react-query/src/gql/graphql.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1303,9 +1303,13 @@ export class TypedDocumentString<TResult, TVariables>
13031303
implements DocumentTypeDecoration<TResult, TVariables>
13041304
{
13051305
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
1306+
private value: string;
1307+
public __meta__?: Record<string, any> | undefined;
13061308

1307-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
1309+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
13081310
super(value);
1311+
this.value = value;
1312+
this.__meta__ = __meta__;
13091313
}
13101314

13111315
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

examples/react/urql/src/gql/graphql.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1303,9 +1303,13 @@ export class TypedDocumentString<TResult, TVariables>
13031303
implements DocumentTypeDecoration<TResult, TVariables>
13041304
{
13051305
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
1306+
private value: string;
1307+
public __meta__?: Record<string, any> | undefined;
13061308

1307-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
1309+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
13081310
super(value);
1311+
this.value = value;
1312+
this.__meta__ = __meta__;
13091313
}
13101314

13111315
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

examples/typescript-graphql-request/src/gql/graphql.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,13 @@ export class TypedDocumentString<TResult, TVariables>
13161316
implements DocumentTypeDecoration<TResult, TVariables>
13171317
{
13181318
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
1319+
private value: string;
1320+
public __meta__?: Record<string, any> | undefined;
13191321

1320-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
1322+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
13211323
super(value);
1324+
this.value = value;
1325+
this.__meta__ = __meta__;
13221326
}
13231327

13241328
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

packages/plugins/typescript/typed-document-node/src/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ export class TypedDocumentString<TResult, TVariables>
4242
implements DocumentTypeDecoration<TResult, TVariables>
4343
{
4444
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
45+
private value: string;
46+
public __meta__?: Record<string, any> | undefined;
4547
46-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
48+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
4749
super(value);
50+
this.value = value;
51+
this.__meta__ = __meta__;
4852
}
4953
5054
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

packages/presets/client/tests/client-preset.spec.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -2464,9 +2464,13 @@ export * from "./gql.js";`);
24642464
implements DocumentTypeDecoration<TResult, TVariables>
24652465
{
24662466
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
2467+
private value: string;
2468+
public __meta__?: Record<string, any> | undefined;
24672469
2468-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
2470+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
24692471
super(value);
2472+
this.value = value;
2473+
this.__meta__ = __meta__;
24702474
}
24712475
24722476
toString(): string & DocumentTypeDecoration<TResult, TVariables> {
@@ -2605,9 +2609,13 @@ export * from "./gql.js";`);
26052609
implements DocumentTypeDecoration<TResult, TVariables>
26062610
{
26072611
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
2612+
private value: string;
2613+
public __meta__?: Record<string, any> | undefined;
26082614
2609-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
2615+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
26102616
super(value);
2617+
this.value = value;
2618+
this.__meta__ = __meta__;
26112619
}
26122620
26132621
toString(): string & DocumentTypeDecoration<TResult, TVariables> {
@@ -2741,9 +2749,13 @@ export * from "./gql.js";`);
27412749
implements DocumentTypeDecoration<TResult, TVariables>
27422750
{
27432751
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
2752+
private value: string;
2753+
public __meta__?: Record<string, any> | undefined;
27442754
2745-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
2755+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
27462756
super(value);
2757+
this.value = value;
2758+
this.__meta__ = __meta__;
27472759
}
27482760
27492761
toString(): string & DocumentTypeDecoration<TResult, TVariables> {
@@ -3036,9 +3048,13 @@ export * from "./gql.js";`);
30363048
implements DocumentTypeDecoration<TResult, TVariables>
30373049
{
30383050
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType'];
3051+
private value: string;
3052+
public __meta__?: Record<string, any> | undefined;
30393053
3040-
constructor(private value: string, public __meta__?: Record<string, any> | undefined) {
3054+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
30413055
super(value);
3056+
this.value = value;
3057+
this.__meta__ = __meta__;
30423058
}
30433059
30443060
toString(): string & DocumentTypeDecoration<TResult, TVariables> {

0 commit comments

Comments
 (0)