Skip to content

Commit f75159b

Browse files
authored
fix: Support using messages called String/Boolean/Number/Array (#934)
* fix: Support using messages called String/Boolean/Number/Array Fixes #927 * chore: bin2ts
1 parent 4fc7940 commit f75159b

File tree

167 files changed

+1440
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1440
-858
lines changed

integration/angular/simple-message.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const SimpleMessage = {
4343
},
4444

4545
fromJSON(object: any): SimpleMessage {
46-
return { numberField: isSet(object.numberField) ? Number(object.numberField) : 0 };
46+
return { numberField: isSet(object.numberField) ? globalThis.Number(object.numberField) : 0 };
4747
},
4848

4949
toJSON(message: SimpleMessage): unknown {
@@ -67,7 +67,8 @@ export const SimpleMessage = {
6767
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
6868

6969
export type DeepPartial<T> = T extends Builtin ? T
70-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
70+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
71+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
7172
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
7273
: Partial<T>;
7374

integration/async-iterable-services-abort-signal/simple.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const EchoMsg = {
7676
},
7777

7878
fromJSON(object: any): EchoMsg {
79-
return { body: isSet(object.body) ? String(object.body) : "" };
79+
return { body: isSet(object.body) ? globalThis.String(object.body) : "" };
8080
},
8181

8282
toJSON(message: EchoMsg): unknown {
@@ -176,7 +176,8 @@ interface Rpc {
176176
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
177177

178178
export type DeepPartial<T> = T extends Builtin ? T
179-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
179+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
180+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
180181
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
181182
: Partial<T>;
182183

integration/async-iterable-services/simple.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const EchoMsg = {
7676
},
7777

7878
fromJSON(object: any): EchoMsg {
79-
return { body: isSet(object.body) ? String(object.body) : "" };
79+
return { body: isSet(object.body) ? globalThis.String(object.body) : "" };
8080
},
8181

8282
toJSON(message: EchoMsg): unknown {
@@ -160,7 +160,8 @@ interface Rpc {
160160
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
161161

162162
export type DeepPartial<T> = T extends Builtin ? T
163-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
163+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
164+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
164165
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
165166
: Partial<T>;
166167

integration/avoid-import-conflicts/simple.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const Simple = {
121121

122122
fromJSON(object: any): Simple {
123123
return {
124-
name: isSet(object.name) ? String(object.name) : "",
124+
name: isSet(object.name) ? globalThis.String(object.name) : "",
125125
otherSimple: isSet(object.otherSimple) ? Simple3.fromJSON(object.otherSimple) : undefined,
126126
};
127127
},
@@ -197,7 +197,7 @@ export const DifferentSimple = {
197197

198198
fromJSON(object: any): DifferentSimple {
199199
return {
200-
name: isSet(object.name) ? String(object.name) : "",
200+
name: isSet(object.name) ? globalThis.String(object.name) : "",
201201
otherOptionalSimple2: isSet(object.otherOptionalSimple2)
202202
? Simple3.fromJSON(object.otherOptionalSimple2)
203203
: undefined,
@@ -443,7 +443,8 @@ interface Rpc {
443443
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
444444

445445
export type DeepPartial<T> = T extends Builtin ? T
446-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
446+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
447+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
447448
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
448449
: Partial<T>;
449450

integration/avoid-import-conflicts/simple2.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ export const Simple = {
132132
},
133133

134134
fromJSON(object: any): Simple {
135-
return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 };
135+
return {
136+
name: isSet(object.name) ? globalThis.String(object.name) : "",
137+
age: isSet(object.age) ? globalThis.Number(object.age) : 0,
138+
};
136139
},
137140

138141
toJSON(message: Simple): unknown {
@@ -160,7 +163,8 @@ export const Simple = {
160163
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
161164

162165
export type DeepPartial<T> = T extends Builtin ? T
163-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
166+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
167+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
164168
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
165169
: Partial<T>;
166170

integration/barrel-imports/bar.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export const Bar = {
5252
},
5353

5454
fromJSON(object: any): Bar {
55-
return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 };
55+
return {
56+
name: isSet(object.name) ? globalThis.String(object.name) : "",
57+
age: isSet(object.age) ? globalThis.Number(object.age) : 0,
58+
};
5659
},
5760

5861
toJSON(message: Bar): unknown {
@@ -80,7 +83,8 @@ export const Bar = {
8083
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
8184

8285
type DeepPartial<T> = T extends Builtin ? T
83-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
86+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
87+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
8488
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
8589
: Partial<T>;
8690

integration/barrel-imports/foo.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const Foo = {
5454

5555
fromJSON(object: any): Foo {
5656
return {
57-
name: isSet(object.name) ? String(object.name) : "",
57+
name: isSet(object.name) ? globalThis.String(object.name) : "",
5858
bar: isSet(object.bar) ? Bar.fromJSON(object.bar) : undefined,
5959
};
6060
},
@@ -84,7 +84,8 @@ export const Foo = {
8484
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
8585

8686
type DeepPartial<T> = T extends Builtin ? T
87-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
87+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
88+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
8889
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
8990
: Partial<T>;
9091

integration/batching-with-context-esModuleInterop/batching.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const BatchQueryRequest = {
8282
},
8383

8484
fromJSON(object: any): BatchQueryRequest {
85-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
85+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
8686
},
8787

8888
toJSON(message: BatchQueryRequest): unknown {
@@ -198,7 +198,7 @@ export const BatchMapQueryRequest = {
198198
},
199199

200200
fromJSON(object: any): BatchMapQueryRequest {
201-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
201+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
202202
},
203203

204204
toJSON(message: BatchMapQueryRequest): unknown {
@@ -344,7 +344,7 @@ export const BatchMapQueryResponse_EntitiesEntry = {
344344

345345
fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry {
346346
return {
347-
key: isSet(object.key) ? String(object.key) : "",
347+
key: isSet(object.key) ? globalThis.String(object.key) : "",
348348
value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined,
349349
};
350350
},
@@ -413,7 +413,7 @@ export const GetOnlyMethodRequest = {
413413
},
414414

415415
fromJSON(object: any): GetOnlyMethodRequest {
416-
return { id: isSet(object.id) ? String(object.id) : "" };
416+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
417417
},
418418

419419
toJSON(message: GetOnlyMethodRequest): unknown {
@@ -529,7 +529,7 @@ export const WriteMethodRequest = {
529529
},
530530

531531
fromJSON(object: any): WriteMethodRequest {
532-
return { id: isSet(object.id) ? String(object.id) : "" };
532+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
533533
},
534534

535535
toJSON(message: WriteMethodRequest): unknown {
@@ -639,7 +639,10 @@ export const Entity = {
639639
},
640640

641641
fromJSON(object: any): Entity {
642-
return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" };
642+
return {
643+
id: isSet(object.id) ? globalThis.String(object.id) : "",
644+
name: isSet(object.name) ? globalThis.String(object.name) : "",
645+
};
643646
},
644647

645648
toJSON(message: Entity): unknown {
@@ -758,7 +761,8 @@ export interface DataLoaders {
758761
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
759762

760763
export type DeepPartial<T> = T extends Builtin ? T
761-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
764+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
765+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
762766
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
763767
: Partial<T>;
764768

integration/batching-with-context/batching.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const BatchQueryRequest = {
8282
},
8383

8484
fromJSON(object: any): BatchQueryRequest {
85-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
85+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
8686
},
8787

8888
toJSON(message: BatchQueryRequest): unknown {
@@ -198,7 +198,7 @@ export const BatchMapQueryRequest = {
198198
},
199199

200200
fromJSON(object: any): BatchMapQueryRequest {
201-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
201+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
202202
},
203203

204204
toJSON(message: BatchMapQueryRequest): unknown {
@@ -344,7 +344,7 @@ export const BatchMapQueryResponse_EntitiesEntry = {
344344

345345
fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry {
346346
return {
347-
key: isSet(object.key) ? String(object.key) : "",
347+
key: isSet(object.key) ? globalThis.String(object.key) : "",
348348
value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined,
349349
};
350350
},
@@ -413,7 +413,7 @@ export const GetOnlyMethodRequest = {
413413
},
414414

415415
fromJSON(object: any): GetOnlyMethodRequest {
416-
return { id: isSet(object.id) ? String(object.id) : "" };
416+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
417417
},
418418

419419
toJSON(message: GetOnlyMethodRequest): unknown {
@@ -529,7 +529,7 @@ export const WriteMethodRequest = {
529529
},
530530

531531
fromJSON(object: any): WriteMethodRequest {
532-
return { id: isSet(object.id) ? String(object.id) : "" };
532+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
533533
},
534534

535535
toJSON(message: WriteMethodRequest): unknown {
@@ -639,7 +639,10 @@ export const Entity = {
639639
},
640640

641641
fromJSON(object: any): Entity {
642-
return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" };
642+
return {
643+
id: isSet(object.id) ? globalThis.String(object.id) : "",
644+
name: isSet(object.name) ? globalThis.String(object.name) : "",
645+
};
643646
},
644647

645648
toJSON(message: Entity): unknown {
@@ -758,7 +761,8 @@ export interface DataLoaders {
758761
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
759762

760763
export type DeepPartial<T> = T extends Builtin ? T
761-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
764+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
765+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
762766
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
763767
: Partial<T>;
764768

integration/batching/batching.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const BatchQueryRequest = {
8080
},
8181

8282
fromJSON(object: any): BatchQueryRequest {
83-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
83+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
8484
},
8585

8686
toJSON(message: BatchQueryRequest): unknown {
@@ -196,7 +196,7 @@ export const BatchMapQueryRequest = {
196196
},
197197

198198
fromJSON(object: any): BatchMapQueryRequest {
199-
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] };
199+
return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] };
200200
},
201201

202202
toJSON(message: BatchMapQueryRequest): unknown {
@@ -342,7 +342,7 @@ export const BatchMapQueryResponse_EntitiesEntry = {
342342

343343
fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry {
344344
return {
345-
key: isSet(object.key) ? String(object.key) : "",
345+
key: isSet(object.key) ? globalThis.String(object.key) : "",
346346
value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined,
347347
};
348348
},
@@ -411,7 +411,7 @@ export const GetOnlyMethodRequest = {
411411
},
412412

413413
fromJSON(object: any): GetOnlyMethodRequest {
414-
return { id: isSet(object.id) ? String(object.id) : "" };
414+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
415415
},
416416

417417
toJSON(message: GetOnlyMethodRequest): unknown {
@@ -527,7 +527,7 @@ export const WriteMethodRequest = {
527527
},
528528

529529
fromJSON(object: any): WriteMethodRequest {
530-
return { id: isSet(object.id) ? String(object.id) : "" };
530+
return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
531531
},
532532

533533
toJSON(message: WriteMethodRequest): unknown {
@@ -637,7 +637,10 @@ export const Entity = {
637637
},
638638

639639
fromJSON(object: any): Entity {
640-
return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" };
640+
return {
641+
id: isSet(object.id) ? globalThis.String(object.id) : "",
642+
name: isSet(object.name) ? globalThis.String(object.name) : "",
643+
};
641644
},
642645

643646
toJSON(message: Entity): unknown {
@@ -715,7 +718,8 @@ interface Rpc {
715718
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
716719

717720
export type DeepPartial<T> = T extends Builtin ? T
718-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
721+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
722+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
719723
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
720724
: Partial<T>;
721725

integration/bytes-as-base64/message.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function base64FromBytes(arr: Uint8Array): string {
6161
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
6262

6363
export type DeepPartial<T> = T extends Builtin ? T
64-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
64+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
65+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
6566
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
6667
: Partial<T>;
6768

0 commit comments

Comments
 (0)