diff --git a/integration/angular/simple-message.ts b/integration/angular/simple-message.ts index 6b578253f..d8c926fec 100644 --- a/integration/angular/simple-message.ts +++ b/integration/angular/simple-message.ts @@ -43,7 +43,7 @@ export const SimpleMessage = { }, fromJSON(object: any): SimpleMessage { - return { numberField: isSet(object.numberField) ? Number(object.numberField) : 0 }; + return { numberField: isSet(object.numberField) ? globalThis.Number(object.numberField) : 0 }; }, toJSON(message: SimpleMessage): unknown { @@ -67,7 +67,8 @@ export const SimpleMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/async-iterable-services-abort-signal/simple.ts b/integration/async-iterable-services-abort-signal/simple.ts index 2c25b9e6d..8c8d47913 100644 --- a/integration/async-iterable-services-abort-signal/simple.ts +++ b/integration/async-iterable-services-abort-signal/simple.ts @@ -76,7 +76,7 @@ export const EchoMsg = { }, fromJSON(object: any): EchoMsg { - return { body: isSet(object.body) ? String(object.body) : "" }; + return { body: isSet(object.body) ? globalThis.String(object.body) : "" }; }, toJSON(message: EchoMsg): unknown { @@ -176,7 +176,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/async-iterable-services/simple.ts b/integration/async-iterable-services/simple.ts index 7321c4b6e..0f85114d0 100644 --- a/integration/async-iterable-services/simple.ts +++ b/integration/async-iterable-services/simple.ts @@ -76,7 +76,7 @@ export const EchoMsg = { }, fromJSON(object: any): EchoMsg { - return { body: isSet(object.body) ? String(object.body) : "" }; + return { body: isSet(object.body) ? globalThis.String(object.body) : "" }; }, toJSON(message: EchoMsg): unknown { @@ -160,7 +160,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/avoid-import-conflicts/simple.ts b/integration/avoid-import-conflicts/simple.ts index 0fd6d0e70..646f2c2c6 100644 --- a/integration/avoid-import-conflicts/simple.ts +++ b/integration/avoid-import-conflicts/simple.ts @@ -121,7 +121,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", otherSimple: isSet(object.otherSimple) ? Simple3.fromJSON(object.otherSimple) : undefined, }; }, @@ -197,7 +197,7 @@ export const DifferentSimple = { fromJSON(object: any): DifferentSimple { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", otherOptionalSimple2: isSet(object.otherOptionalSimple2) ? Simple3.fromJSON(object.otherOptionalSimple2) : undefined, @@ -443,7 +443,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/avoid-import-conflicts/simple2.ts b/integration/avoid-import-conflicts/simple2.ts index 57968f6bb..c842a7c0f 100644 --- a/integration/avoid-import-conflicts/simple2.ts +++ b/integration/avoid-import-conflicts/simple2.ts @@ -132,7 +132,10 @@ export const Simple = { }, fromJSON(object: any): Simple { - return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; + return { + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, + }; }, toJSON(message: Simple): unknown { @@ -160,7 +163,8 @@ export const Simple = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/barrel-imports/bar.ts b/integration/barrel-imports/bar.ts index 70156a00a..ad0c51de7 100644 --- a/integration/barrel-imports/bar.ts +++ b/integration/barrel-imports/bar.ts @@ -52,7 +52,10 @@ export const Bar = { }, fromJSON(object: any): Bar { - return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; + return { + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, + }; }, toJSON(message: Bar): unknown { @@ -80,7 +83,8 @@ export const Bar = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/barrel-imports/foo.ts b/integration/barrel-imports/foo.ts index c7f833d97..290ea5d32 100644 --- a/integration/barrel-imports/foo.ts +++ b/integration/barrel-imports/foo.ts @@ -54,7 +54,7 @@ export const Foo = { fromJSON(object: any): Foo { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", bar: isSet(object.bar) ? Bar.fromJSON(object.bar) : undefined, }; }, @@ -84,7 +84,8 @@ export const Foo = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/batching-with-context-esModuleInterop/batching.ts b/integration/batching-with-context-esModuleInterop/batching.ts index d98b83e4b..fc7c79a77 100644 --- a/integration/batching-with-context-esModuleInterop/batching.ts +++ b/integration/batching-with-context-esModuleInterop/batching.ts @@ -82,7 +82,7 @@ export const BatchQueryRequest = { }, fromJSON(object: any): BatchQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchQueryRequest): unknown { @@ -198,7 +198,7 @@ export const BatchMapQueryRequest = { }, fromJSON(object: any): BatchMapQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchMapQueryRequest): unknown { @@ -344,7 +344,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -413,7 +413,7 @@ export const GetOnlyMethodRequest = { }, fromJSON(object: any): GetOnlyMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: GetOnlyMethodRequest): unknown { @@ -529,7 +529,7 @@ export const WriteMethodRequest = { }, fromJSON(object: any): WriteMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: WriteMethodRequest): unknown { @@ -639,7 +639,10 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" }; + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", + }; }, toJSON(message: Entity): unknown { @@ -758,7 +761,8 @@ export interface DataLoaders { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/batching-with-context/batching.ts b/integration/batching-with-context/batching.ts index 7f598d5c0..b99cecca2 100644 --- a/integration/batching-with-context/batching.ts +++ b/integration/batching-with-context/batching.ts @@ -82,7 +82,7 @@ export const BatchQueryRequest = { }, fromJSON(object: any): BatchQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchQueryRequest): unknown { @@ -198,7 +198,7 @@ export const BatchMapQueryRequest = { }, fromJSON(object: any): BatchMapQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchMapQueryRequest): unknown { @@ -344,7 +344,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -413,7 +413,7 @@ export const GetOnlyMethodRequest = { }, fromJSON(object: any): GetOnlyMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: GetOnlyMethodRequest): unknown { @@ -529,7 +529,7 @@ export const WriteMethodRequest = { }, fromJSON(object: any): WriteMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: WriteMethodRequest): unknown { @@ -639,7 +639,10 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" }; + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", + }; }, toJSON(message: Entity): unknown { @@ -758,7 +761,8 @@ export interface DataLoaders { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/batching/batching.ts b/integration/batching/batching.ts index d8f317e24..4b71dd37c 100644 --- a/integration/batching/batching.ts +++ b/integration/batching/batching.ts @@ -80,7 +80,7 @@ export const BatchQueryRequest = { }, fromJSON(object: any): BatchQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchQueryRequest): unknown { @@ -196,7 +196,7 @@ export const BatchMapQueryRequest = { }, fromJSON(object: any): BatchMapQueryRequest { - return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; + return { ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e: any) => globalThis.String(e)) : [] }; }, toJSON(message: BatchMapQueryRequest): unknown { @@ -342,7 +342,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -411,7 +411,7 @@ export const GetOnlyMethodRequest = { }, fromJSON(object: any): GetOnlyMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: GetOnlyMethodRequest): unknown { @@ -527,7 +527,7 @@ export const WriteMethodRequest = { }, fromJSON(object: any): WriteMethodRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; + return { id: isSet(object.id) ? globalThis.String(object.id) : "" }; }, toJSON(message: WriteMethodRequest): unknown { @@ -637,7 +637,10 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" }; + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", + }; }, toJSON(message: Entity): unknown { @@ -715,7 +718,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/bytes-as-base64/message.ts b/integration/bytes-as-base64/message.ts index d2fde563c..8fd805d0c 100644 --- a/integration/bytes-as-base64/message.ts +++ b/integration/bytes-as-base64/message.ts @@ -61,7 +61,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/bytes-node/google/protobuf/wrappers.ts b/integration/bytes-node/google/protobuf/wrappers.ts index 3733bd145..79a5e79e4 100644 --- a/integration/bytes-node/google/protobuf/wrappers.ts +++ b/integration/bytes-node/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/bytes-node/point.ts b/integration/bytes-node/point.ts index 5ba70ad87..8bb3222a0 100644 --- a/integration/bytes-node/point.ts +++ b/integration/bytes-node/point.ts @@ -111,7 +111,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/const-enum/const-enum.ts b/integration/const-enum/const-enum.ts index 675148027..85c341609 100644 --- a/integration/const-enum/const-enum.ts +++ b/integration/const-enum/const-enum.ts @@ -217,7 +217,7 @@ export const DividerData_TypeMapEntry = { fromJSON(object: any): DividerData_TypeMapEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? dividerData_DividerTypeFromJSON(object.value) : DividerData_DividerType.DOUBLE, }; }, @@ -247,7 +247,8 @@ export const DividerData_TypeMapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/emit-default-values-json/google/protobuf/timestamp.ts b/integration/emit-default-values-json/google/protobuf/timestamp.ts index 03a7220b9..b38b58970 100644 --- a/integration/emit-default-values-json/google/protobuf/timestamp.ts +++ b/integration/emit-default-values-json/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/emit-default-values-json/test.ts b/integration/emit-default-values-json/test.ts index a5e6867ce..a2aef5f94 100644 --- a/integration/emit-default-values-json/test.ts +++ b/integration/emit-default-values-json/test.ts @@ -410,28 +410,30 @@ export const DefaultValuesTest = { fromJSON(object: any): DefaultValuesTest { return { - id: isSet(object.id) ? Number(object.id) : 0, + id: isSet(object.id) ? globalThis.Number(object.id) : 0, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, - long: isSet(object.long) ? Number(object.long) : 0, - truth: isSet(object.truth) ? Boolean(object.truth) : false, - description: isSet(object.description) ? String(object.description) : "", + long: isSet(object.long) ? globalThis.Number(object.long) : 0, + truth: isSet(object.truth) ? globalThis.Boolean(object.truth) : false, + description: isSet(object.description) ? globalThis.String(object.description) : "", data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => Number(e)) : [], + repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => globalThis.Number(e)) : [], repChild: globalThis.Array.isArray(object?.repChild) ? object.repChild.map((e: any) => Child.fromJSON(e)) : [], repState: globalThis.Array.isArray(object?.repState) ? object.repState.map((e: any) => stateEnumFromJSON(e)) : [], - repLong: globalThis.Array.isArray(object?.repLong) ? object.repLong.map((e: any) => Number(e)) : [], - repTruth: globalThis.Array.isArray(object?.repTruth) ? object.repTruth.map((e: any) => Boolean(e)) : [], + repLong: globalThis.Array.isArray(object?.repLong) ? object.repLong.map((e: any) => globalThis.Number(e)) : [], + repTruth: globalThis.Array.isArray(object?.repTruth) + ? object.repTruth.map((e: any) => globalThis.Boolean(e)) + : [], repDescription: globalThis.Array.isArray(object?.repDescription) - ? object.repDescription.map((e: any) => String(e)) + ? object.repDescription.map((e: any) => globalThis.String(e)) : [], repData: globalThis.Array.isArray(object?.repData) ? object.repData.map((e: any) => bytesFromBase64(e)) : [], - optId: isSet(object.optId) ? Number(object.optId) : undefined, + optId: isSet(object.optId) ? globalThis.Number(object.optId) : undefined, optChild: isSet(object.optChild) ? Child.fromJSON(object.optChild) : undefined, optState: isSet(object.optState) ? stateEnumFromJSON(object.optState) : undefined, - optLong: isSet(object.optLong) ? Number(object.optLong) : undefined, - optTruth: isSet(object.optTruth) ? Boolean(object.optTruth) : undefined, - optDescription: isSet(object.optDescription) ? String(object.optDescription) : undefined, + optLong: isSet(object.optLong) ? globalThis.Number(object.optLong) : undefined, + optTruth: isSet(object.optTruth) ? globalThis.Boolean(object.optTruth) : undefined, + optDescription: isSet(object.optDescription) ? globalThis.String(object.optDescription) : undefined, optData: isSet(object.optData) ? bytesFromBase64(object.optData) : undefined, translations: isObject(object.translations) ? Object.entries(object.translations).reduce<{ [key: string]: string }>((acc, [key, value]) => { @@ -554,7 +556,7 @@ export const DefaultValuesTest = { message.translations = Object.entries(object.translations ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -611,7 +613,10 @@ export const DefaultValuesTest_TranslationsEntry = { }, fromJSON(object: any): DefaultValuesTest_TranslationsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: DefaultValuesTest_TranslationsEntry): unknown { @@ -711,7 +716,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts index 4b80bfae2..f39181458 100644 --- a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts +++ b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts @@ -130,7 +130,8 @@ export const DividerData = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/enums-as-literals/enums-as-literals.ts b/integration/enums-as-literals/enums-as-literals.ts index 62b27838f..25ab5e740 100644 --- a/integration/enums-as-literals/enums-as-literals.ts +++ b/integration/enums-as-literals/enums-as-literals.ts @@ -108,7 +108,8 @@ export const DividerData = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/extensions/test.ts b/integration/extensions/test.ts index dd7ea9e87..f0ac4bfdd 100644 --- a/integration/extensions/test.ts +++ b/integration/extensions/test.ts @@ -174,7 +174,7 @@ export const Extendable = { }, fromJSON(object: any): Extendable { - return { field: isSet(object.field) ? String(object.field) : undefined }; + return { field: isSet(object.field) ? globalThis.String(object.field) : undefined }; }, toJSON(message: Extendable): unknown { @@ -283,7 +283,7 @@ export const Nested = { }, fromJSON(object: any): Nested { - return { field: isSet(object.field) ? String(object.field) : undefined }; + return { field: isSet(object.field) ? globalThis.String(object.field) : undefined }; }, toJSON(message: Nested): unknown { @@ -378,8 +378,8 @@ export const Group = { fromJSON(object: any): Group { return { - name: isSet(object.name) ? String(object.name) : undefined, - value: isSet(object.value) ? String(object.value) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + value: isSet(object.value) ? globalThis.String(object.value) : undefined, }; }, @@ -596,7 +596,7 @@ export const group: Extension = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/fieldmask/fieldmask.ts b/integration/fieldmask/fieldmask.ts index 9ec4344e1..4ab450588 100644 --- a/integration/fieldmask/fieldmask.ts +++ b/integration/fieldmask/fieldmask.ts @@ -68,7 +68,8 @@ export const FieldMaskMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/fieldmask/google/protobuf/field_mask.ts b/integration/fieldmask/google/protobuf/field_mask.ts index 14147ad36..4cd875a67 100644 --- a/integration/fieldmask/google/protobuf/field_mask.ts +++ b/integration/fieldmask/google/protobuf/field_mask.ts @@ -280,7 +280,8 @@ export const FieldMask = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/file-suffix/child.pb.ts b/integration/file-suffix/child.pb.ts index d4fd6dcd8..344c0afb9 100644 --- a/integration/file-suffix/child.pb.ts +++ b/integration/file-suffix/child.pb.ts @@ -76,7 +76,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -100,7 +100,8 @@ export const Child = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/file-suffix/google/protobuf/timestamp.pb.ts b/integration/file-suffix/google/protobuf/timestamp.pb.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/file-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/file-suffix/google/protobuf/timestamp.pb.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/file-suffix/parent.pb.ts b/integration/file-suffix/parent.pb.ts index 548440681..d7a0ebb8c 100644 --- a/integration/file-suffix/parent.pb.ts +++ b/integration/file-suffix/parent.pb.ts @@ -103,7 +103,8 @@ export const Parent = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/from-partial-no-initialize/test.ts b/integration/from-partial-no-initialize/test.ts index 9cae047ca..342276e9b 100644 --- a/integration/from-partial-no-initialize/test.ts +++ b/integration/from-partial-no-initialize/test.ts @@ -58,7 +58,7 @@ export const TPartialMessage = { }, fromJSON(object: any): TPartialMessage { - return { field: isSet(object.field) ? String(object.field) : undefined }; + return { field: isSet(object.field) ? globalThis.String(object.field) : undefined }; }, toJSON(message: TPartialMessage): unknown { @@ -212,8 +212,8 @@ export const TPartial = { fromJSON(object: any): TPartial { return { - number: isSet(object.number) ? Number(object.number) : undefined, - string: isSet(object.string) ? String(object.string) : undefined, + number: isSet(object.number) ? globalThis.Number(object.number) : undefined, + string: isSet(object.string) ? globalThis.String(object.string) : undefined, map: isObject(object.map) ? Object.entries(object.map).reduce<{ [key: string]: string }>((acc, [key, value]) => { acc[key] = String(value); @@ -225,10 +225,10 @@ export const TPartial = { ? object.repeatedMessage.map((e: any) => TPartialMessage.fromJSON(e)) : undefined, repeatedString: globalThis.Array.isArray(object?.repeatedString) - ? object.repeatedString.map((e: any) => String(e)) + ? object.repeatedString.map((e: any) => globalThis.String(e)) : undefined, repeatedNumber: globalThis.Array.isArray(object?.repeatedNumber) - ? object.repeatedNumber.map((e: any) => Number(e)) + ? object.repeatedNumber.map((e: any) => globalThis.Number(e)) : undefined, }; }, @@ -276,7 +276,7 @@ export const TPartial = { ? undefined : Object.entries(object.map ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, {}); @@ -336,7 +336,10 @@ export const TPartial_MapEntry = { }, fromJSON(object: any): TPartial_MapEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: TPartial_MapEntry): unknown { @@ -364,7 +367,8 @@ export const TPartial_MapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index 28f4e1b41..8f4cf2943 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -60,7 +60,7 @@ export const HeroById = { }, fromJSON(object: any): HeroById { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: HeroById): unknown { @@ -117,7 +117,7 @@ export const VillainById = { }, fromJSON(object: any): VillainById { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: VillainById): unknown { @@ -184,7 +184,10 @@ export const Hero = { }, fromJSON(object: any): Hero { - return { id: isSet(object.id) ? Number(object.id) : 0, name: isSet(object.name) ? String(object.name) : "" }; + return { + id: isSet(object.id) ? globalThis.Number(object.id) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + }; }, toJSON(message: Hero): unknown { @@ -255,7 +258,10 @@ export const Villain = { }, fromJSON(object: any): Villain { - return { id: isSet(object.id) ? Number(object.id) : 0, name: isSet(object.name) ? String(object.name) : "" }; + return { + id: isSet(object.id) ? globalThis.Number(object.id) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + }; }, toJSON(message: Villain): unknown { @@ -358,7 +364,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index 28066f995..1f978d8e9 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -43,7 +43,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: TestMessage): unknown { @@ -133,7 +133,8 @@ export const TestDefinition = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index 28066f995..1f978d8e9 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -43,7 +43,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: TestMessage): unknown { @@ -133,7 +133,8 @@ export const TestDefinition = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/global-this/global-this-test.ts b/integration/global-this/global-this-test.ts index 0c912dd47..364c64874 100644 --- a/integration/global-this/global-this-test.ts +++ b/integration/global-this/global-this-test.ts @@ -1,8 +1,12 @@ -import { Object, Error } from './global-this'; +import { Object, Error, String, Boolean, Number, Array } from "./global-this"; -describe('global-this', () => { - it('generates types correctly', () => { +describe("global-this", () => { + it("generates types correctly", () => { Object.fromPartial({}); Error.fromPartial({}); + String.fromPartial({}); + Boolean.fromPartial({}); + Number.fromPartial({}); + Array.fromPartial({}); }); }); diff --git a/integration/global-this/global-this.bin b/integration/global-this/global-this.bin index 4a39e83e8..9e29a07b9 100644 Binary files a/integration/global-this/global-this.bin and b/integration/global-this/global-this.bin differ diff --git a/integration/global-this/global-this.proto b/integration/global-this/global-this.proto index 949fda8e6..95f370cae 100644 --- a/integration/global-this/global-this.proto +++ b/integration/global-this/global-this.proto @@ -8,3 +8,19 @@ message Object { message Error { string name = 1; } + +message String { + string value = 1; +} + +message Boolean { + bool value = 1; +} + +message Number { + double value = 1; +} + +message Array { + repeated String values = 1; +} diff --git a/integration/global-this/global-this.ts b/integration/global-this/global-this.ts index 39b07ba67..fa3b2654c 100644 --- a/integration/global-this/global-this.ts +++ b/integration/global-this/global-this.ts @@ -11,6 +11,22 @@ export interface Error { name: string; } +export interface String { + value: string; +} + +export interface Boolean { + value: boolean; +} + +export interface Number { + value: number; +} + +export interface Array { + values: String[]; +} + function createBaseObject(): Object { return { name: "" }; } @@ -47,7 +63,7 @@ export const Object = { }, fromJSON(object: any): Object { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? gt.String(object.name) : "" }; }, toJSON(message: Object): unknown { @@ -104,7 +120,7 @@ export const Error = { }, fromJSON(object: any): Error { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? gt.String(object.name) : "" }; }, toJSON(message: Error): unknown { @@ -125,10 +141,258 @@ export const Error = { }, }; +function createBaseString(): String { + return { value: "" }; +} + +export const String = { + encode(message: String, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== "") { + writer.uint32(10).string(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): String { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseString(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.value = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): String { + return { value: isSet(object.value) ? gt.String(object.value) : "" }; + }, + + toJSON(message: String): unknown { + const obj: any = {}; + if (message.value !== "") { + obj.value = message.value; + } + return obj; + }, + + create, I>>(base?: I): String { + return String.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): String { + const message = createBaseString(); + message.value = object.value ?? ""; + return message; + }, +}; + +function createBaseBoolean(): Boolean { + return { value: false }; +} + +export const Boolean = { + encode(message: Boolean, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value === true) { + writer.uint32(8).bool(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Boolean { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBoolean(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.value = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): Boolean { + return { value: isSet(object.value) ? gt.Boolean(object.value) : false }; + }, + + toJSON(message: Boolean): unknown { + const obj: any = {}; + if (message.value === true) { + obj.value = message.value; + } + return obj; + }, + + create, I>>(base?: I): Boolean { + return Boolean.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Boolean { + const message = createBaseBoolean(); + message.value = object.value ?? false; + return message; + }, +}; + +function createBaseNumber(): Number { + return { value: 0 }; +} + +export const Number = { + encode(message: Number, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(9).double(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Number { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseNumber(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 9) { + break; + } + + message.value = reader.double(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): Number { + return { value: isSet(object.value) ? gt.Number(object.value) : 0 }; + }, + + toJSON(message: Number): unknown { + const obj: any = {}; + if (message.value !== 0) { + obj.value = message.value; + } + return obj; + }, + + create, I>>(base?: I): Number { + return Number.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Number { + const message = createBaseNumber(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseArray(): Array { + return { values: [] }; +} + +export const Array = { + encode(message: Array, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.values) { + String.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Array { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseArray(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.values.push(String.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): Array { + return { values: gt.Array.isArray(object?.values) ? object.values.map((e: any) => String.fromJSON(e)) : [] }; + }, + + toJSON(message: Array): unknown { + const obj: any = {}; + if (message.values?.length) { + obj.values = message.values.map((e) => String.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): Array { + return Array.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Array { + const message = createBaseArray(); + message.values = object.values?.map((e) => String.fromPartial(e)) || []; + return message; + }, +}; + +declare const self: any | undefined; +declare const window: any | undefined; +declare const global: any | undefined; +const gt: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/groups/test.ts b/integration/groups/test.ts index 76f11de6e..4b601ce63 100644 --- a/integration/groups/test.ts +++ b/integration/groups/test.ts @@ -135,9 +135,9 @@ export const GroupsOptionalTest = { fromJSON(object: any): GroupsOptionalTest { return { - int1: isSet(object.int1) ? Number(object.int1) : undefined, + int1: isSet(object.int1) ? globalThis.Number(object.int1) : undefined, group: isSet(object.group) ? GroupsOptionalTest_Group.fromJSON(object.group) : undefined, - int3: isSet(object.int3) ? Number(object.int3) : undefined, + int3: isSet(object.int3) ? globalThis.Number(object.int3) : undefined, }; }, @@ -243,8 +243,8 @@ export const GroupsOptionalTest_Group = { fromJSON(object: any): GroupsOptionalTest_Group { return { - key: isSet(object.key) ? String(object.key) : undefined, - value: isSet(object.value) ? String(object.value) : undefined, + key: isSet(object.key) ? globalThis.String(object.key) : undefined, + value: isSet(object.value) ? globalThis.String(object.value) : undefined, }; }, @@ -399,11 +399,11 @@ export const GroupsRepeatedTest = { fromJSON(object: any): GroupsRepeatedTest { return { - int1: globalThis.Array.isArray(object?.int1) ? object.int1.map((e: any) => Number(e)) : undefined, + int1: globalThis.Array.isArray(object?.int1) ? object.int1.map((e: any) => globalThis.Number(e)) : undefined, group: globalThis.Array.isArray(object?.group) ? object.group.map((e: any) => GroupsRepeatedTest_Group.fromJSON(e)) : undefined, - int3: globalThis.Array.isArray(object?.int3) ? object.int3.map((e: any) => Number(e)) : undefined, + int3: globalThis.Array.isArray(object?.int3) ? object.int3.map((e: any) => globalThis.Number(e)) : undefined, }; }, @@ -517,8 +517,8 @@ export const GroupsRepeatedTest_Group = { fromJSON(object: any): GroupsRepeatedTest_Group { return { - key: globalThis.Array.isArray(object?.key) ? object.key.map((e: any) => String(e)) : undefined, - value: globalThis.Array.isArray(object?.value) ? object.value.map((e: any) => String(e)) : undefined, + key: globalThis.Array.isArray(object?.key) ? object.key.map((e: any) => globalThis.String(e)) : undefined, + value: globalThis.Array.isArray(object?.value) ? object.value.map((e: any) => globalThis.String(e)) : undefined, }; }, @@ -673,11 +673,11 @@ export const GroupsNestedTest = { fromJSON(object: any): GroupsNestedTest { return { - int1: globalThis.Array.isArray(object?.int1) ? object.int1.map((e: any) => Number(e)) : undefined, + int1: globalThis.Array.isArray(object?.int1) ? object.int1.map((e: any) => globalThis.Number(e)) : undefined, group: globalThis.Array.isArray(object?.group) ? object.group.map((e: any) => GroupsNestedTest_Group.fromJSON(e)) : undefined, - int3: globalThis.Array.isArray(object?.int3) ? object.int3.map((e: any) => Number(e)) : undefined, + int3: globalThis.Array.isArray(object?.int3) ? object.int3.map((e: any) => globalThis.Number(e)) : undefined, }; }, @@ -958,7 +958,7 @@ export const GroupsNestedTest_Group_Nested_Nested2 = { }, fromJSON(object: any): GroupsNestedTest_Group_Nested_Nested2 { - return { string1: isSet(object.string1) ? String(object.string1) : undefined }; + return { string1: isSet(object.string1) ? globalThis.String(object.string1) : undefined }; }, toJSON(message: GroupsNestedTest_Group_Nested_Nested2): unknown { @@ -986,7 +986,8 @@ export const GroupsNestedTest_Group_Nested_Nested2 = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts b/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts index 11ad8eeec..6191ec2fd 100644 --- a/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts +++ b/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts @@ -141,7 +141,8 @@ export const TestClient = makeGenericClientConstructor(TestService, "simple.Test type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts b/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts index abd5e3ccd..dc19a1e7c 100644 --- a/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts +++ b/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts @@ -139,7 +139,8 @@ export const TestClient = makeGenericClientConstructor(TestService, "simple.Test type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts b/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts index e22366a39..29d456ab3 100644 --- a/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts +++ b/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts @@ -139,7 +139,8 @@ export const TestClient = makeGenericClientConstructor(TestService, "simple.Test type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js/google/protobuf/empty.ts b/integration/grpc-js/google/protobuf/empty.ts index 5f012de45..b43712c5b 100644 --- a/integration/grpc-js/google/protobuf/empty.ts +++ b/integration/grpc-js/google/protobuf/empty.ts @@ -63,7 +63,8 @@ export const Empty = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js/google/protobuf/struct.ts b/integration/grpc-js/google/protobuf/struct.ts index 1fbd240e3..3a8e3f4b9 100644 --- a/integration/grpc-js/google/protobuf/struct.ts +++ b/integration/grpc-js/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js/google/protobuf/wrappers.ts b/integration/grpc-js/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/grpc-js/google/protobuf/wrappers.ts +++ b/integration/grpc-js/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-js/simple.ts b/integration/grpc-js/simple.ts index 9d4d4946b..32ae5d001 100644 --- a/integration/grpc-js/simple.ts +++ b/integration/grpc-js/simple.ts @@ -636,7 +636,8 @@ export const TestClient = makeGenericClientConstructor(TestService, "simple.Test type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-web-abort-signal/example.ts b/integration/grpc-web-abort-signal/example.ts index 2d5fc9fd8..00cf13280 100644 --- a/integration/grpc-web-abort-signal/example.ts +++ b/integration/grpc-web-abort-signal/example.ts @@ -142,7 +142,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : "", + msg: isSet(object.msg) ? globalThis.String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -226,7 +226,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : "", + email: isSet(object.email) ? globalThis.String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: globalThis.Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -307,8 +307,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", + connectGoogle: isSet(object.connectGoogle) ? globalThis.String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? globalThis.String(object.connectGithub) : "", }; }, @@ -401,10 +401,10 @@ export const DashCred = { fromJSON(object: any): DashCred { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - token: isSet(object.token) ? String(object.token) : "", - id: isSet(object.id) ? String(object.id) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + token: isSet(object.token) ? globalThis.String(object.token) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -485,8 +485,8 @@ export const DashAPICredsCreateReq = { fromJSON(object: any): DashAPICredsCreateReq { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", }; }, @@ -579,10 +579,10 @@ export const DashAPICredsUpdateReq = { fromJSON(object: any): DashAPICredsUpdateReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -663,8 +663,8 @@ export const DashAPICredsDeleteReq = { fromJSON(object: any): DashAPICredsDeleteReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -1102,7 +1102,8 @@ export class GrpcWebImpl { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-web-go-server/example.ts b/integration/grpc-web-go-server/example.ts index c4617b40b..f7e13410e 100644 --- a/integration/grpc-web-go-server/example.ts +++ b/integration/grpc-web-go-server/example.ts @@ -140,7 +140,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : "", + msg: isSet(object.msg) ? globalThis.String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -224,7 +224,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : "", + email: isSet(object.email) ? globalThis.String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: globalThis.Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -305,8 +305,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", + connectGoogle: isSet(object.connectGoogle) ? globalThis.String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? globalThis.String(object.connectGithub) : "", }; }, @@ -399,10 +399,10 @@ export const DashCred = { fromJSON(object: any): DashCred { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - token: isSet(object.token) ? String(object.token) : "", - id: isSet(object.id) ? String(object.id) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + token: isSet(object.token) ? globalThis.String(object.token) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -483,8 +483,8 @@ export const DashAPICredsCreateReq = { fromJSON(object: any): DashAPICredsCreateReq { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", }; }, @@ -577,10 +577,10 @@ export const DashAPICredsUpdateReq = { fromJSON(object: any): DashAPICredsUpdateReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -661,8 +661,8 @@ export const DashAPICredsDeleteReq = { fromJSON(object: any): DashAPICredsDeleteReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -810,7 +810,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-web-no-streaming-observable/example.ts b/integration/grpc-web-no-streaming-observable/example.ts index 09727110f..c2a82a9df 100644 --- a/integration/grpc-web-no-streaming-observable/example.ts +++ b/integration/grpc-web-no-streaming-observable/example.ts @@ -118,7 +118,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : "", + msg: isSet(object.msg) ? globalThis.String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -202,7 +202,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : "", + email: isSet(object.email) ? globalThis.String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: globalThis.Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -283,8 +283,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", + connectGoogle: isSet(object.connectGoogle) ? globalThis.String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? globalThis.String(object.connectGithub) : "", }; }, @@ -471,7 +471,8 @@ export class GrpcWebImpl { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-web-no-streaming/example.ts b/integration/grpc-web-no-streaming/example.ts index 4d69775dd..9143fdc8f 100644 --- a/integration/grpc-web-no-streaming/example.ts +++ b/integration/grpc-web-no-streaming/example.ts @@ -116,7 +116,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : "", + msg: isSet(object.msg) ? globalThis.String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -200,7 +200,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : "", + email: isSet(object.email) ? globalThis.String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: globalThis.Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -281,8 +281,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", + connectGoogle: isSet(object.connectGoogle) ? globalThis.String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? globalThis.String(object.connectGithub) : "", }; }, @@ -468,7 +468,8 @@ export class GrpcWebImpl { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/grpc-web/example.ts b/integration/grpc-web/example.ts index 2b57770fd..6a4f4afe0 100644 --- a/integration/grpc-web/example.ts +++ b/integration/grpc-web/example.ts @@ -142,7 +142,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : "", + msg: isSet(object.msg) ? globalThis.String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -226,7 +226,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : "", + email: isSet(object.email) ? globalThis.String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: globalThis.Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -307,8 +307,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", + connectGoogle: isSet(object.connectGoogle) ? globalThis.String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? globalThis.String(object.connectGithub) : "", }; }, @@ -401,10 +401,10 @@ export const DashCred = { fromJSON(object: any): DashCred { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - token: isSet(object.token) ? String(object.token) : "", - id: isSet(object.id) ? String(object.id) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + token: isSet(object.token) ? globalThis.String(object.token) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -485,8 +485,8 @@ export const DashAPICredsCreateReq = { fromJSON(object: any): DashAPICredsCreateReq { return { - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", }; }, @@ -579,10 +579,10 @@ export const DashAPICredsUpdateReq = { fromJSON(object: any): DashAPICredsUpdateReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - description: isSet(object.description) ? String(object.description) : "", - metadata: isSet(object.metadata) ? String(object.metadata) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + description: isSet(object.description) ? globalThis.String(object.description) : "", + metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -663,8 +663,8 @@ export const DashAPICredsDeleteReq = { fromJSON(object: any): DashAPICredsDeleteReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : "", - id: isSet(object.id) ? String(object.id) : "", + credSid: isSet(object.credSid) ? globalThis.String(object.credSid) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, @@ -1040,7 +1040,8 @@ export class GrpcWebImpl { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/import-mapping/google/protobuf/timestamp.ts b/integration/import-mapping/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/import-mapping/google/protobuf/timestamp.ts +++ b/integration/import-mapping/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/import-mapping/mapping.ts b/integration/import-mapping/mapping.ts index 69be657a7..8800ed517 100644 --- a/integration/import-mapping/mapping.ts +++ b/integration/import-mapping/mapping.ts @@ -325,7 +325,8 @@ export const WithAll = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/import-suffix/child.pb.ts b/integration/import-suffix/child.pb.ts index 8e07ba1b1..1666ca356 100644 --- a/integration/import-suffix/child.pb.ts +++ b/integration/import-suffix/child.pb.ts @@ -76,7 +76,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -100,7 +100,8 @@ export const Child = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/import-suffix/google/protobuf/timestamp.pb.ts b/integration/import-suffix/google/protobuf/timestamp.pb.ts index cd239f79d..447ba735e 100644 --- a/integration/import-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/import-suffix/google/protobuf/timestamp.pb.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/import-suffix/parent.pb.ts b/integration/import-suffix/parent.pb.ts index bc5f653cb..48210d877 100644 --- a/integration/import-suffix/parent.pb.ts +++ b/integration/import-suffix/parent.pb.ts @@ -103,7 +103,8 @@ export const Parent = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/lower-case-svc-methods/math.ts b/integration/lower-case-svc-methods/math.ts index e9558cf70..401ecf22b 100644 --- a/integration/lower-case-svc-methods/math.ts +++ b/integration/lower-case-svc-methods/math.ts @@ -64,7 +64,10 @@ export const NumPair = { }, fromJSON(object: any): NumPair { - return { num1: isSet(object.num1) ? Number(object.num1) : 0, num2: isSet(object.num2) ? Number(object.num2) : 0 }; + return { + num1: isSet(object.num1) ? globalThis.Number(object.num1) : 0, + num2: isSet(object.num2) ? globalThis.Number(object.num2) : 0, + }; }, toJSON(message: NumPair): unknown { @@ -125,7 +128,7 @@ export const NumSingle = { }, fromJSON(object: any): NumSingle { - return { num: isSet(object.num) ? Number(object.num) : 0 }; + return { num: isSet(object.num) ? globalThis.Number(object.num) : 0 }; }, toJSON(message: NumSingle): unknown { @@ -194,7 +197,7 @@ export const Numbers = { }, fromJSON(object: any): Numbers { - return { num: globalThis.Array.isArray(object?.num) ? object.num.map((e: any) => Number(e)) : [] }; + return { num: globalThis.Array.isArray(object?.num) ? object.num.map((e: any) => globalThis.Number(e)) : [] }; }, toJSON(message: Numbers): unknown { @@ -278,7 +281,8 @@ export interface DataLoaders { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/map-bigint-optional/test.ts b/integration/map-bigint-optional/test.ts index 19f092464..83b3163f2 100644 --- a/integration/map-bigint-optional/test.ts +++ b/integration/map-bigint-optional/test.ts @@ -227,7 +227,8 @@ export const MapBigInt_MapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/map-long-optional/test.ts b/integration/map-long-optional/test.ts index e37f85cd5..d9df61afa 100644 --- a/integration/map-long-optional/test.ts +++ b/integration/map-long-optional/test.ts @@ -227,7 +227,7 @@ export const MapBigInt_MapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/map-longstring-optional/test.ts b/integration/map-longstring-optional/test.ts index 0710cf04d..776cfce64 100644 --- a/integration/map-longstring-optional/test.ts +++ b/integration/map-longstring-optional/test.ts @@ -114,7 +114,7 @@ export const MapBigInt = { const m = new Map(); (object.map as Map ?? new Map()).forEach((value, key) => { if (value !== undefined) { - m.set(key, String(value)); + m.set(key, globalThis.String(value)); } }); return m; @@ -197,8 +197,8 @@ export const MapBigInt_MapEntry = { fromJSON(object: any): MapBigInt_MapEntry { return { - key: isSet(object.key) ? String(object.key) : "0", - value: isSet(object.value) ? String(object.value) : "0", + key: isSet(object.key) ? globalThis.String(object.key) : "0", + value: isSet(object.value) ? globalThis.String(object.value) : "0", }; }, @@ -227,7 +227,8 @@ export const MapBigInt_MapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/nice-grpc/google/protobuf/empty.ts b/integration/nice-grpc/google/protobuf/empty.ts index 15f57b3c9..21fddf8fe 100644 --- a/integration/nice-grpc/google/protobuf/empty.ts +++ b/integration/nice-grpc/google/protobuf/empty.ts @@ -63,6 +63,7 @@ export const Empty = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/nice-grpc/google/protobuf/struct.ts b/integration/nice-grpc/google/protobuf/struct.ts index 3a66cccd4..1c9ada703 100644 --- a/integration/nice-grpc/google/protobuf/struct.ts +++ b/integration/nice-grpc/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/nice-grpc/google/protobuf/timestamp.ts b/integration/nice-grpc/google/protobuf/timestamp.ts index 500536f18..3d4edd591 100644 --- a/integration/nice-grpc/google/protobuf/timestamp.ts +++ b/integration/nice-grpc/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/nice-grpc/google/protobuf/wrappers.ts b/integration/nice-grpc/google/protobuf/wrappers.ts index 3e74ece15..4ccec88e4 100644 --- a/integration/nice-grpc/google/protobuf/wrappers.ts +++ b/integration/nice-grpc/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index b33cfb4bb..c9824f0a8 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -374,7 +374,8 @@ export interface TestClient { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/no-proto-package/no-proto-package.ts b/integration/no-proto-package/no-proto-package.ts index 06c3a3251..bbc99c042 100644 --- a/integration/no-proto-package/no-proto-package.ts +++ b/integration/no-proto-package/no-proto-package.ts @@ -48,7 +48,7 @@ export const User = { }, fromJSON(object: any): User { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: User): unknown { @@ -142,7 +142,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/omit-optionals/simple.ts b/integration/omit-optionals/simple.ts index 038972b4c..1582908ee 100644 --- a/integration/omit-optionals/simple.ts +++ b/integration/omit-optionals/simple.ts @@ -55,8 +55,8 @@ export const TestMessage = { fromJSON(object: any): TestMessage { return { - field1: isSet(object.field1) ? Boolean(object.field1) : false, - field2: isSet(object.field2) ? Boolean(object.field2) : undefined, + field1: isSet(object.field1) ? globalThis.Boolean(object.field1) : false, + field2: isSet(object.field2) ? globalThis.Boolean(object.field2) : undefined, }; }, @@ -85,7 +85,8 @@ export const TestMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/oneof-properties/oneof.ts b/integration/oneof-properties/oneof.ts index 2aa5a5315..0c18d89f1 100644 --- a/integration/oneof-properties/oneof.ts +++ b/integration/oneof-properties/oneof.ts @@ -225,17 +225,17 @@ export const PleaseChoose = { fromJSON(object: any): PleaseChoose { return { - name: isSet(object.name) ? String(object.name) : "", - aNumber: isSet(object.aNumber) ? Number(object.aNumber) : undefined, - aString: isSet(object.aString) ? String(object.aString) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : "", + aNumber: isSet(object.aNumber) ? globalThis.Number(object.aNumber) : undefined, + aString: isSet(object.aString) ? globalThis.String(object.aString) : undefined, aMessage: isSet(object.aMessage) ? PleaseChoose_Submessage.fromJSON(object.aMessage) : undefined, - aBool: isSet(object.aBool) ? Boolean(object.aBool) : undefined, + aBool: isSet(object.aBool) ? globalThis.Boolean(object.aBool) : undefined, bunchaBytes: isSet(object.bunchaBytes) ? bytesFromBase64(object.bunchaBytes) : undefined, anEnum: isSet(object.anEnum) ? pleaseChoose_StateEnumFromJSON(object.anEnum) : undefined, - age: isSet(object.age) ? Number(object.age) : 0, - either: isSet(object.either) ? String(object.either) : undefined, - or: isSet(object.or) ? String(object.or) : undefined, - thirdOption: isSet(object.thirdOption) ? String(object.thirdOption) : undefined, + age: isSet(object.age) ? globalThis.Number(object.age) : 0, + either: isSet(object.either) ? globalThis.String(object.either) : undefined, + or: isSet(object.or) ? globalThis.String(object.or) : undefined, + thirdOption: isSet(object.thirdOption) ? globalThis.String(object.thirdOption) : undefined, }; }, @@ -335,7 +335,7 @@ export const PleaseChoose_Submessage = { }, fromJSON(object: any): PleaseChoose_Submessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: PleaseChoose_Submessage): unknown { @@ -384,7 +384,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/oneof-unions-snake/google/protobuf/struct.ts b/integration/oneof-unions-snake/google/protobuf/struct.ts index a71a5b6d5..1a528b610 100644 --- a/integration/oneof-unions-snake/google/protobuf/struct.ts +++ b/integration/oneof-unions-snake/google/protobuf/struct.ts @@ -235,7 +235,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -355,11 +358,11 @@ export const Value = { kind: isSet(object.null_value) ? { $case: "null_value", null_value: nullValueFromJSON(object.null_value) } : isSet(object.number_value) - ? { $case: "number_value", number_value: Number(object.number_value) } + ? { $case: "number_value", number_value: globalThis.Number(object.number_value) } : isSet(object.string_value) - ? { $case: "string_value", string_value: String(object.string_value) } + ? { $case: "string_value", string_value: globalThis.String(object.string_value) } : isSet(object.bool_value) - ? { $case: "bool_value", bool_value: Boolean(object.bool_value) } + ? { $case: "bool_value", bool_value: globalThis.Boolean(object.bool_value) } : isSet(object.struct_value) ? { $case: "struct_value", struct_value: object.struct_value } : isSet(object.list_value) @@ -548,7 +551,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/oneof-unions-snake/simple.ts b/integration/oneof-unions-snake/simple.ts index ee106ecbe..5c454a07c 100644 --- a/integration/oneof-unions-snake/simple.ts +++ b/integration/oneof-unions-snake/simple.ts @@ -73,7 +73,8 @@ export const SimpleStruct = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/oneof-unions/google/protobuf/struct.ts b/integration/oneof-unions/google/protobuf/struct.ts index 58eee70d7..93f15fe19 100644 --- a/integration/oneof-unions/google/protobuf/struct.ts +++ b/integration/oneof-unions/google/protobuf/struct.ts @@ -235,7 +235,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -352,11 +355,11 @@ export const Value = { kind: isSet(object.nullValue) ? { $case: "nullValue", nullValue: nullValueFromJSON(object.nullValue) } : isSet(object.numberValue) - ? { $case: "numberValue", numberValue: Number(object.numberValue) } + ? { $case: "numberValue", numberValue: globalThis.Number(object.numberValue) } : isSet(object.stringValue) - ? { $case: "stringValue", stringValue: String(object.stringValue) } + ? { $case: "stringValue", stringValue: globalThis.String(object.stringValue) } : isSet(object.boolValue) - ? { $case: "boolValue", boolValue: Boolean(object.boolValue) } + ? { $case: "boolValue", boolValue: globalThis.Boolean(object.boolValue) } : isSet(object.structValue) ? { $case: "structValue", structValue: object.structValue } : isSet(object.listValue) @@ -539,7 +542,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/oneof-unions/oneof.ts b/integration/oneof-unions/oneof.ts index 459afef80..350ae2922 100644 --- a/integration/oneof-unions/oneof.ts +++ b/integration/oneof-unions/oneof.ts @@ -233,27 +233,27 @@ export const PleaseChoose = { fromJSON(object: any): PleaseChoose { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", choice: isSet(object.aNumber) - ? { $case: "aNumber", aNumber: Number(object.aNumber) } + ? { $case: "aNumber", aNumber: globalThis.Number(object.aNumber) } : isSet(object.aString) - ? { $case: "aString", aString: String(object.aString) } + ? { $case: "aString", aString: globalThis.String(object.aString) } : isSet(object.aMessage) ? { $case: "aMessage", aMessage: PleaseChoose_Submessage.fromJSON(object.aMessage) } : isSet(object.aBool) - ? { $case: "aBool", aBool: Boolean(object.aBool) } + ? { $case: "aBool", aBool: globalThis.Boolean(object.aBool) } : isSet(object.bunchaBytes) ? { $case: "bunchaBytes", bunchaBytes: bytesFromBase64(object.bunchaBytes) } : isSet(object.anEnum) ? { $case: "anEnum", anEnum: pleaseChoose_StateEnumFromJSON(object.anEnum) } : undefined, - age: isSet(object.age) ? Number(object.age) : 0, + age: isSet(object.age) ? globalThis.Number(object.age) : 0, eitherOr: isSet(object.either) - ? { $case: "either", either: String(object.either) } + ? { $case: "either", either: globalThis.String(object.either) } : isSet(object.or) - ? { $case: "or", or: String(object.or) } + ? { $case: "or", or: globalThis.String(object.or) } : isSet(object.thirdOption) - ? { $case: "thirdOption", thirdOption: String(object.thirdOption) } + ? { $case: "thirdOption", thirdOption: globalThis.String(object.thirdOption) } : undefined, signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0), value: isSet(object?.value) ? object.value : undefined, @@ -392,7 +392,7 @@ export const PleaseChoose_Submessage = { }, fromJSON(object: any): PleaseChoose_Submessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: PleaseChoose_Submessage): unknown { @@ -460,8 +460,8 @@ export const SimpleButOptional = { fromJSON(object: any): SimpleButOptional { return { - name: isSet(object.name) ? String(object.name) : undefined, - age: isSet(object.age) ? Number(object.age) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + age: isSet(object.age) ? globalThis.Number(object.age) : undefined, }; }, @@ -515,7 +515,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/output-fromJSON-only/decode.ts b/integration/output-fromJSON-only/decode.ts index 50ab78201..0bfd0e63b 100644 --- a/integration/output-fromJSON-only/decode.ts +++ b/integration/output-fromJSON-only/decode.ts @@ -8,7 +8,7 @@ export interface Encode { export const Encode = { fromJSON(object: any): Encode { - return { encode: isSet(object.encode) ? String(object.encode) : "" }; + return { encode: isSet(object.encode) ? globalThis.String(object.encode) : "" }; }, }; diff --git a/integration/output-fromJSON-only/google/protobuf/wrappers.ts b/integration/output-fromJSON-only/google/protobuf/wrappers.ts index 0469421f6..80cfd3a33 100644 --- a/integration/output-fromJSON-only/google/protobuf/wrappers.ts +++ b/integration/output-fromJSON-only/google/protobuf/wrappers.ts @@ -94,49 +94,49 @@ export interface BytesValue { export const DoubleValue = { fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const FloatValue = { fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const Int64Value = { fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const UInt64Value = { fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const Int32Value = { fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const UInt32Value = { fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, }; export const BoolValue = { fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, }; export const StringValue = { fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, }; diff --git a/integration/output-index/a.ts b/integration/output-index/a.ts index a6cabe256..d2b61cf6e 100644 --- a/integration/output-index/a.ts +++ b/integration/output-index/a.ts @@ -41,7 +41,7 @@ export const A = { }, fromJSON(object: any): A { - return { a: isSet(object.a) ? String(object.a) : "" }; + return { a: isSet(object.a) ? globalThis.String(object.a) : "" }; }, toJSON(message: A): unknown { @@ -65,7 +65,8 @@ export const A = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/point/point.ts b/integration/point/point.ts index 718fffd7b..1a3ba3406 100644 --- a/integration/point/point.ts +++ b/integration/point/point.ts @@ -59,7 +59,10 @@ export const Point = { }, fromJSON(object: any): Point { - return { lat: isSet(object.lat) ? Number(object.lat) : 0, lng: isSet(object.lng) ? Number(object.lng) : 0 }; + return { + lat: isSet(object.lat) ? globalThis.Number(object.lat) : 0, + lng: isSet(object.lng) ? globalThis.Number(object.lng) : 0, + }; }, toJSON(message: Point): unknown { @@ -161,7 +164,8 @@ export const Area = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/remove-enum-prefix-string-enums/remove-enum-prefix-string-enums.ts b/integration/remove-enum-prefix-string-enums/remove-enum-prefix-string-enums.ts index d192683dc..85ebed5fd 100644 --- a/integration/remove-enum-prefix-string-enums/remove-enum-prefix-string-enums.ts +++ b/integration/remove-enum-prefix-string-enums/remove-enum-prefix-string-enums.ts @@ -314,7 +314,8 @@ export const WithNestedEnum = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/remove-enum-prefix/remove-enum-prefix.ts b/integration/remove-enum-prefix/remove-enum-prefix.ts index fa297be92..ecf814647 100644 --- a/integration/remove-enum-prefix/remove-enum-prefix.ts +++ b/integration/remove-enum-prefix/remove-enum-prefix.ts @@ -257,7 +257,8 @@ export const WithNestedEnum = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/reserved-words/reserved-words.ts b/integration/reserved-words/reserved-words.ts index 169fcc963..c7192c998 100644 --- a/integration/reserved-words/reserved-words.ts +++ b/integration/reserved-words/reserved-words.ts @@ -52,7 +52,8 @@ export const Record = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/return-observable/observable.ts b/integration/return-observable/observable.ts index df4e45875..9e6bac934 100644 --- a/integration/return-observable/observable.ts +++ b/integration/return-observable/observable.ts @@ -48,7 +48,7 @@ export const ProduceRequest = { }, fromJSON(object: any): ProduceRequest { - return { ingredients: isSet(object.ingredients) ? String(object.ingredients) : "" }; + return { ingredients: isSet(object.ingredients) ? globalThis.String(object.ingredients) : "" }; }, toJSON(message: ProduceRequest): unknown { @@ -105,7 +105,7 @@ export const ProduceReply = { }, fromJSON(object: any): ProduceReply { - return { result: isSet(object.result) ? String(object.result) : "" }; + return { result: isSet(object.result) ? globalThis.String(object.result) : "" }; }, toJSON(message: ProduceReply): unknown { @@ -133,7 +133,8 @@ export interface Factory { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-deprecated-fields/simple.ts b/integration/simple-deprecated-fields/simple.ts index 30248068f..198652acb 100644 --- a/integration/simple-deprecated-fields/simple.ts +++ b/integration/simple-deprecated-fields/simple.ts @@ -110,11 +110,11 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, - testField: isSet(object.testField) ? String(object.testField) : "", - testNotDeprecated: isSet(object.testNotDeprecated) ? String(object.testNotDeprecated) : "", + testField: isSet(object.testField) ? globalThis.String(object.testField) : "", + testNotDeprecated: isSet(object.testNotDeprecated) ? globalThis.String(object.testNotDeprecated) : "", }; }, @@ -188,7 +188,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -212,7 +212,8 @@ export const Child = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-esmodule-interop/simple.ts b/integration/simple-esmodule-interop/simple.ts index 612f0b920..3f6013ec6 100644 --- a/integration/simple-esmodule-interop/simple.ts +++ b/integration/simple-esmodule-interop/simple.ts @@ -70,7 +70,10 @@ export const Simple = { }, fromJSON(object: any): Simple { - return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; + return { + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, + }; }, toJSON(message: Simple): unknown { @@ -255,18 +258,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -335,7 +338,8 @@ export const Numbers = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-json-name/google/protobuf/timestamp.ts b/integration/simple-json-name/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/simple-json-name/google/protobuf/timestamp.ts +++ b/integration/simple-json-name/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-json-name/simple.ts b/integration/simple-json-name/simple.ts index 2f7f14f0c..f89562f37 100644 --- a/integration/simple-json-name/simple.ts +++ b/integration/simple-json-name/simple.ts @@ -131,15 +131,15 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.other_name) ? String(object.other_name) : "", - age: isSet(object.other_age) ? Number(object.other_age) : undefined, + name: isSet(object.other_name) ? globalThis.String(object.other_name) : "", + age: isSet(object.other_age) ? globalThis.Number(object.other_age) : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - hyphen: isSet(object["hyphened-name"]) ? String(object["hyphened-name"]) : "", - spaces: isSet(object["name with spaces"]) ? String(object["name with spaces"]) : "", - dollarStart: isSet(object.$dollar) ? String(object.$dollar) : "", - dollarEnd: isSet(object.dollar$) ? String(object.dollar$) : "", + hyphen: isSet(object["hyphened-name"]) ? globalThis.String(object["hyphened-name"]) : "", + spaces: isSet(object["name with spaces"]) ? globalThis.String(object["name with spaces"]) : "", + dollarStart: isSet(object.$dollar) ? globalThis.String(object.$dollar) : "", + dollarEnd: isSet(object.dollar$) ? globalThis.String(object.dollar$) : "", hyphenList: globalThis.Array.isArray(object?.["hyphen-list"]) - ? object["hyphen-list"].map((e: any) => String(e)) + ? object["hyphen-list"].map((e: any) => globalThis.String(e)) : [], }; }, @@ -193,7 +193,8 @@ export const Simple = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-bigint/google/protobuf/timestamp.ts b/integration/simple-long-bigint/google/protobuf/timestamp.ts index 6fbfc8858..7808d3a03 100644 --- a/integration/simple-long-bigint/google/protobuf/timestamp.ts +++ b/integration/simple-long-bigint/google/protobuf/timestamp.ts @@ -159,7 +159,7 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { seconds: isSet(object.seconds) ? BigInt(object.seconds) : BigInt("0"), - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-bigint/google/protobuf/wrappers.ts b/integration/simple-long-bigint/google/protobuf/wrappers.ts index ddfc5c942..2f9fc2ab9 100644 --- a/integration/simple-long-bigint/google/protobuf/wrappers.ts +++ b/integration/simple-long-bigint/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-bigint/simple.ts b/integration/simple-long-bigint/simple.ts index 5a3b26970..9605f5862 100644 --- a/integration/simple-long-bigint/simple.ts +++ b/integration/simple-long-bigint/simple.ts @@ -229,17 +229,17 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, int64: isSet(object.int64) ? BigInt(object.int64) : BigInt("0"), - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, uint64: isSet(object.uint64) ? BigInt(object.uint64) : BigInt("0"), - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, sint64: isSet(object.sint64) ? BigInt(object.sint64) : BigInt("0"), - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, fixed64: isSet(object.fixed64) ? BigInt(object.fixed64) : BigInt("0"), - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, sfixed64: isSet(object.sfixed64) ? BigInt(object.sfixed64) : BigInt("0"), guint64: isSet(object.guint64) ? BigInt(object.guint64) : undefined, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, @@ -324,7 +324,8 @@ export const Numbers = { type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-string/google/protobuf/timestamp.ts b/integration/simple-long-string/google/protobuf/timestamp.ts index 261126610..f44912e94 100644 --- a/integration/simple-long-string/google/protobuf/timestamp.ts +++ b/integration/simple-long-string/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? String(object.seconds) : "0", - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.String(object.seconds) : "0", + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-string/google/protobuf/wrappers.ts b/integration/simple-long-string/google/protobuf/wrappers.ts index 64cf9eda8..881f6fc9e 100644 --- a/integration/simple-long-string/google/protobuf/wrappers.ts +++ b/integration/simple-long-string/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? String(object.value) : "0" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "0" }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? String(object.value) : "0" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "0" }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long-string/simple.ts b/integration/simple-long-string/simple.ts index a6917b35e..05f93999f 100644 --- a/integration/simple-long-string/simple.ts +++ b/integration/simple-long-string/simple.ts @@ -205,18 +205,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? String(object.int64) : "0", - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? String(object.uint64) : "0", - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? String(object.sint64) : "0", - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? String(object.fixed64) : "0", - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? String(object.sfixed64) : "0", + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.String(object.int64) : "0", + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.String(object.uint64) : "0", + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.String(object.sint64) : "0", + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.String(object.fixed64) : "0", + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.String(object.sfixed64) : "0", guint64: isSet(object.guint64) ? String(object.guint64) : undefined, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, }; @@ -295,7 +295,8 @@ export const Numbers = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long/google/protobuf/wrappers.ts b/integration/simple-long/google/protobuf/wrappers.ts index 1ed04d466..420b56ab2 100644 --- a/integration/simple-long/google/protobuf/wrappers.ts +++ b/integration/simple-long/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,7 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index 263c5bc5f..b5f70d6cd 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -312,7 +312,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -321,7 +321,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -386,7 +386,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -459,7 +462,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -743,17 +749,17 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, int64: isSet(object.int64) ? Long.fromValue(object.int64) : Long.ZERO, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, uint64: isSet(object.uint64) ? Long.fromValue(object.uint64) : Long.UZERO, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, sint64: isSet(object.sint64) ? Long.fromValue(object.sint64) : Long.ZERO, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, fixed64: isSet(object.fixed64) ? Long.fromValue(object.fixed64) : Long.UZERO, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, sfixed64: isSet(object.sfixed64) ? Long.fromValue(object.sfixed64) : Long.ZERO, manyUint64: globalThis.Array.isArray(object?.manyUint64) ? object.manyUint64.map((e: any) => Long.fromValue(e)) @@ -838,7 +844,7 @@ export const Numbers = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-optionals/google/protobuf/timestamp.ts b/integration/simple-optionals/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/simple-optionals/google/protobuf/timestamp.ts +++ b/integration/simple-optionals/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-optionals/google/protobuf/wrappers.ts b/integration/simple-optionals/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/simple-optionals/google/protobuf/wrappers.ts +++ b/integration/simple-optionals/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-optionals/import_dir/thing.ts b/integration/simple-optionals/import_dir/thing.ts index 6e534663c..f4e27d406 100644 --- a/integration/simple-optionals/import_dir/thing.ts +++ b/integration/simple-optionals/import_dir/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-optionals/simple.ts b/integration/simple-optionals/simple.ts index a41a17140..8e446f144 100644 --- a/integration/simple-optionals/simple.ts +++ b/integration/simple-optionals/simple.ts @@ -400,16 +400,16 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, grandChildren: globalThis.Array.isArray(object?.grandChildren) ? object.grandChildren.map((e: any) => Child.fromJSON(e)) : [], - coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Number(e)) : [], - snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => String(e)) : [], + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => globalThis.Number(e)) : [], + snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => globalThis.String(e)) : [], oldStates: globalThis.Array.isArray(object?.oldStates) ? object.oldStates.map((e: any) => stateEnumFromJSON(e)) : [], @@ -520,7 +520,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -604,7 +604,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -685,7 +685,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -750,7 +750,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -820,8 +820,8 @@ export const OneOfMessage = { fromJSON(object: any): OneOfMessage { return { - first: isSet(object.first) ? String(object.first) : undefined, - last: isSet(object.last) ? String(object.last) : undefined, + first: isSet(object.first) ? globalThis.String(object.first) : undefined, + last: isSet(object.last) ? globalThis.String(object.last) : undefined, }; }, @@ -1002,7 +1002,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1159,7 +1159,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -1168,7 +1168,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1225,7 +1225,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1302,7 +1302,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1375,7 +1378,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1528,7 +1534,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithSnakeCaseMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1597,7 +1603,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { input: isSet(object.input) ? String(object.input) : "" }; + return { input: isSet(object.input) ? globalThis.String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1654,7 +1660,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { output: isSet(object.output) ? String(object.output) : "" }; + return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1835,18 +1841,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -1939,7 +1945,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-optionals/thing.ts b/integration/simple-optionals/thing.ts index 38c56ba8b..b5da9edcc 100644 --- a/integration/simple-optionals/thing.ts +++ b/integration/simple-optionals/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-proto2/simple.ts b/integration/simple-proto2/simple.ts index 7068e093e..0d69b7886 100644 --- a/integration/simple-proto2/simple.ts +++ b/integration/simple-proto2/simple.ts @@ -100,7 +100,8 @@ export const Issue56 = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts index 562616fca..641e84c16 100644 --- a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts +++ b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts index 2a043867a..e60727dd1 100644 --- a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts +++ b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-prototype-defaults/google/type/date.ts b/integration/simple-prototype-defaults/google/type/date.ts index b7b14eccc..28dd048f2 100644 --- a/integration/simple-prototype-defaults/google/type/date.ts +++ b/integration/simple-prototype-defaults/google/type/date.ts @@ -91,9 +91,9 @@ export const DateMessage = { fromJSON(object: any): DateMessage { return { - year: isSet(object.year) ? Number(object.year) : 0, - month: isSet(object.month) ? Number(object.month) : 0, - day: isSet(object.day) ? Number(object.day) : 0, + year: isSet(object.year) ? globalThis.Number(object.year) : 0, + month: isSet(object.month) ? globalThis.Number(object.month) : 0, + day: isSet(object.day) ? globalThis.Number(object.day) : 0, }; }, @@ -126,7 +126,8 @@ export const DateMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-prototype-defaults/import_dir/thing.ts b/integration/simple-prototype-defaults/import_dir/thing.ts index 7c6a9e205..426053cff 100644 --- a/integration/simple-prototype-defaults/import_dir/thing.ts +++ b/integration/simple-prototype-defaults/import_dir/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-prototype-defaults/simple.ts b/integration/simple-prototype-defaults/simple.ts index 564321f67..7d9bdb633 100644 --- a/integration/simple-prototype-defaults/simple.ts +++ b/integration/simple-prototype-defaults/simple.ts @@ -495,16 +495,16 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, grandChildren: globalThis.Array.isArray(object?.grandChildren) ? object.grandChildren.map((e: any) => Child.fromJSON(e)) : [], - coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Number(e)) : [], - snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => String(e)) : [], + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => globalThis.Number(e)) : [], + snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => globalThis.String(e)) : [], oldStates: globalThis.Array.isArray(object?.oldStates) ? object.oldStates.map((e: any) => stateEnumFromJSON(e)) : [], @@ -632,7 +632,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -716,7 +716,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -797,7 +797,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -862,7 +862,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -932,8 +932,8 @@ export const OneOfMessage = { fromJSON(object: any): OneOfMessage { return { - first: isSet(object.first) ? String(object.first) : undefined, - last: isSet(object.last) ? String(object.last) : undefined, + first: isSet(object.first) ? globalThis.String(object.first) : undefined, + last: isSet(object.last) ? globalThis.String(object.last) : undefined, }; }, @@ -1129,7 +1129,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1411,7 +1411,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -1420,7 +1420,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1455,7 +1455,7 @@ export const SimpleWithMap = { message.longLookup = Object.entries(object.longLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1512,7 +1512,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1589,7 +1589,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1662,7 +1665,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1734,7 +1740,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { fromJSON(object: any): SimpleWithMap_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -1812,7 +1818,7 @@ export const SimpleWithMap_MapOfBytesEntry = { fromJSON(object: any): SimpleWithMap_MapOfBytesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0), }; }, @@ -1890,7 +1896,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { fromJSON(object: any): SimpleWithMap_MapOfStringValuesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? String(object.value) : undefined, }; }, @@ -1969,7 +1975,10 @@ export const SimpleWithMap_LongLookupEntry = { }, fromJSON(object: any): SimpleWithMap_LongLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_LongLookupEntry): unknown { @@ -2126,7 +2135,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithSnakeCaseMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -2291,7 +2300,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { fromJSON(object: any): SimpleWithMapOfEnums_EnumsByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? stateEnumFromJSON(object.value) : 0, }; }, @@ -2360,7 +2369,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { input: isSet(object.input) ? String(object.input) : "" }; + return { input: isSet(object.input) ? globalThis.String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -2417,7 +2426,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { output: isSet(object.output) ? String(object.output) : "" }; + return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -2598,18 +2607,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -2780,8 +2789,8 @@ export const SimpleButOptional = { fromJSON(object: any): SimpleButOptional { return { - name: isSet(object.name) ? String(object.name) : undefined, - age: isSet(object.age) ? Number(object.age) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + age: isSet(object.age) ? globalThis.Number(object.age) : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : undefined, @@ -2931,7 +2940,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-snake/google/protobuf/struct.ts b/integration/simple-snake/google/protobuf/struct.ts index b619c1a28..c9995ba7e 100644 --- a/integration/simple-snake/google/protobuf/struct.ts +++ b/integration/simple-snake/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, - number_value: isSet(object.number_value) ? Number(object.number_value) : undefined, - string_value: isSet(object.string_value) ? String(object.string_value) : undefined, - bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + number_value: isSet(object.number_value) ? globalThis.Number(object.number_value) : undefined, + string_value: isSet(object.string_value) ? globalThis.String(object.string_value) : undefined, + bool_value: isSet(object.bool_value) ? globalThis.Boolean(object.bool_value) : undefined, struct_value: isObject(object.struct_value) ? object.struct_value : undefined, list_value: globalThis.Array.isArray(object.list_value) ? [...object.list_value] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-snake/google/protobuf/timestamp.ts b/integration/simple-snake/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/simple-snake/google/protobuf/timestamp.ts +++ b/integration/simple-snake/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-snake/google/protobuf/wrappers.ts b/integration/simple-snake/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/simple-snake/google/protobuf/wrappers.ts +++ b/integration/simple-snake/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-snake/import_dir/thing.ts b/integration/simple-snake/import_dir/thing.ts index c782ec4d8..5f80dc135 100644 --- a/integration/simple-snake/import_dir/thing.ts +++ b/integration/simple-snake/import_dir/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-snake/simple.ts b/integration/simple-snake/simple.ts index 5fccb0ec1..2fc3b1294 100644 --- a/integration/simple-snake/simple.ts +++ b/integration/simple-snake/simple.ts @@ -405,16 +405,16 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, created_at: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, grand_children: globalThis.Array.isArray(object?.grand_children) ? object.grand_children.map((e: any) => Child.fromJSON(e)) : [], - coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Number(e)) : [], - snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => String(e)) : [], + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => globalThis.Number(e)) : [], + snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => globalThis.String(e)) : [], old_states: globalThis.Array.isArray(object?.old_states) ? object.old_states.map((e: any) => stateEnumFromJSON(e)) : [], @@ -525,7 +525,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -609,7 +609,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -690,7 +690,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -755,7 +755,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -825,8 +825,8 @@ export const OneOfMessage = { fromJSON(object: any): OneOfMessage { return { - first: isSet(object.first) ? String(object.first) : undefined, - last: isSet(object.last) ? String(object.last) : undefined, + first: isSet(object.first) ? globalThis.String(object.first) : undefined, + last: isSet(object.last) ? globalThis.String(object.last) : undefined, }; }, @@ -1007,7 +1007,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1164,7 +1164,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -1173,7 +1173,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1230,7 +1230,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1307,7 +1307,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1380,7 +1383,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1533,7 +1539,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithSnakeCaseMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1602,7 +1608,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { input: isSet(object.input) ? String(object.input) : "" }; + return { input: isSet(object.input) ? globalThis.String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1659,7 +1665,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { output: isSet(object.output) ? String(object.output) : "" }; + return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1840,18 +1846,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -2001,7 +2007,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-string-enums/google/protobuf/struct.ts b/integration/simple-string-enums/google/protobuf/struct.ts index d86becab5..6e9861e1e 100644 --- a/integration/simple-string-enums/google/protobuf/struct.ts +++ b/integration/simple-string-enums/google/protobuf/struct.ts @@ -259,7 +259,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -379,9 +382,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -536,7 +539,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-string-enums/simple.ts b/integration/simple-string-enums/simple.ts index bacb46e0f..4873245b5 100644 --- a/integration/simple-string-enums/simple.ts +++ b/integration/simple-string-enums/simple.ts @@ -162,7 +162,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", state: isSet(object.state) ? stateEnumFromJSON(object.state) : StateEnum.UNKNOWN, states: globalThis.Array.isArray(object?.states) ? object.states.map((e: any) => stateEnumFromJSON(e)) : [], nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : NullValue.NULL_VALUE, @@ -270,7 +270,7 @@ export const Simple_StateMapEntry = { fromJSON(object: any): Simple_StateMapEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? stateEnumFromJSON(object.value) : StateEnum.UNKNOWN, }; }, @@ -300,7 +300,8 @@ export const Simple_StateMapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-unrecognized-enum/import_dir/thing.ts b/integration/simple-unrecognized-enum/import_dir/thing.ts index c14794156..0fe76ebd1 100644 --- a/integration/simple-unrecognized-enum/import_dir/thing.ts +++ b/integration/simple-unrecognized-enum/import_dir/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple-unrecognized-enum/simple.ts b/integration/simple-unrecognized-enum/simple.ts index a76524d34..fe8a7b066 100644 --- a/integration/simple-unrecognized-enum/simple.ts +++ b/integration/simple-unrecognized-enum/simple.ts @@ -388,16 +388,16 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, grandChildren: globalThis.Array.isArray(object?.grandChildren) ? object.grandChildren.map((e: any) => Child.fromJSON(e)) : [], - coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Number(e)) : [], - snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => String(e)) : [], + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => globalThis.Number(e)) : [], + snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => globalThis.String(e)) : [], oldStates: globalThis.Array.isArray(object?.oldStates) ? object.oldStates.map((e: any) => stateEnumFromJSON(e)) : [], @@ -508,7 +508,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -592,7 +592,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -673,7 +673,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -738,7 +738,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -808,8 +808,8 @@ export const OneOfMessage = { fromJSON(object: any): OneOfMessage { return { - first: isSet(object.first) ? String(object.first) : undefined, - last: isSet(object.last) ? String(object.last) : undefined, + first: isSet(object.first) ? globalThis.String(object.first) : undefined, + last: isSet(object.last) ? globalThis.String(object.last) : undefined, }; }, @@ -990,7 +990,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1147,7 +1147,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -1156,7 +1156,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1213,7 +1213,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1290,7 +1290,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1363,7 +1366,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1516,7 +1522,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithSnakeCaseMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1585,7 +1591,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { input: isSet(object.input) ? String(object.input) : "" }; + return { input: isSet(object.input) ? globalThis.String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1642,7 +1648,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { output: isSet(object.output) ? String(object.output) : "" }; + return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1823,18 +1829,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -1927,7 +1933,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple/google/protobuf/wrappers.ts b/integration/simple/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/simple/google/protobuf/wrappers.ts +++ b/integration/simple/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple/google/type/date.ts b/integration/simple/google/type/date.ts index fa3432109..ad231208b 100644 --- a/integration/simple/google/type/date.ts +++ b/integration/simple/google/type/date.ts @@ -91,9 +91,9 @@ export const DateMessage = { fromJSON(object: any): DateMessage { return { - year: isSet(object.year) ? Number(object.year) : 0, - month: isSet(object.month) ? Number(object.month) : 0, - day: isSet(object.day) ? Number(object.day) : 0, + year: isSet(object.year) ? globalThis.Number(object.year) : 0, + month: isSet(object.month) ? globalThis.Number(object.month) : 0, + day: isSet(object.day) ? globalThis.Number(object.day) : 0, }; }, @@ -126,7 +126,8 @@ export const DateMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple/import_dir/thing.ts b/integration/simple/import_dir/thing.ts index c14794156..0fe76ebd1 100644 --- a/integration/simple/import_dir/thing.ts +++ b/integration/simple/import_dir/thing.ts @@ -68,7 +68,8 @@ export const ImportedThing = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/simple/simple.ts b/integration/simple/simple.ts index 023bea748..a611e5a7b 100644 --- a/integration/simple/simple.ts +++ b/integration/simple/simple.ts @@ -513,16 +513,16 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", - age: isSet(object.age) ? Number(object.age) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", + age: isSet(object.age) ? globalThis.Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, grandChildren: globalThis.Array.isArray(object?.grandChildren) ? object.grandChildren.map((e: any) => Child.fromJSON(e)) : [], - coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Number(e)) : [], - snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => String(e)) : [], + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => globalThis.Number(e)) : [], + snacks: globalThis.Array.isArray(object?.snacks) ? object.snacks.map((e: any) => globalThis.String(e)) : [], oldStates: globalThis.Array.isArray(object?.oldStates) ? object.oldStates.map((e: any) => stateEnumFromJSON(e)) : [], @@ -530,7 +530,7 @@ export const Simple = { blobs: globalThis.Array.isArray(object?.blobs) ? object.blobs.map((e: any) => bytesFromBase64(e)) : [], birthday: isSet(object.birthday) ? DateMessage.fromJSON(object.birthday) : undefined, blob: isSet(object.blob) ? bytesFromBase64(object.blob) : new Uint8Array(0), - enabled: isSet(object.enabled) ? Boolean(object.enabled) : false, + enabled: isSet(object.enabled) ? globalThis.Boolean(object.enabled) : false, }; }, @@ -655,7 +655,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -739,7 +739,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -820,7 +820,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -885,7 +885,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { name: isSet(object.name) ? String(object.name) : "" }; + return { name: isSet(object.name) ? globalThis.String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -955,8 +955,8 @@ export const OneOfMessage = { fromJSON(object: any): OneOfMessage { return { - first: isSet(object.first) ? String(object.first) : undefined, - last: isSet(object.last) ? String(object.last) : undefined, + first: isSet(object.first) ? globalThis.String(object.first) : undefined, + last: isSet(object.last) ? globalThis.String(object.last) : undefined, }; }, @@ -1152,7 +1152,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1460,7 +1460,7 @@ export const SimpleWithMap = { message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -1469,7 +1469,7 @@ export const SimpleWithMap = { message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1504,7 +1504,7 @@ export const SimpleWithMap = { message.longLookup = Object.entries(object.longLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { if (value !== undefined) { - acc[globalThis.Number(key)] = Number(value); + acc[globalThis.Number(key)] = globalThis.Number(value); } return acc; }, @@ -1514,7 +1514,7 @@ export const SimpleWithMap = { const m = new Map(); (object.boolLookup as Map ?? new Map()).forEach((value, key) => { if (value !== undefined) { - m.set(key, Number(value)); + m.set(key, globalThis.Number(value)); } }); return m; @@ -1570,7 +1570,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -1647,7 +1647,10 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1720,7 +1723,10 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1792,7 +1798,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { fromJSON(object: any): SimpleWithMap_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -1870,7 +1876,7 @@ export const SimpleWithMap_MapOfBytesEntry = { fromJSON(object: any): SimpleWithMap_MapOfBytesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0), }; }, @@ -1946,7 +1952,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { fromJSON(object: any): SimpleWithMap_MapOfStringValuesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? String(object.value) : undefined, }; }, @@ -2023,7 +2029,10 @@ export const SimpleWithMap_LongLookupEntry = { }, fromJSON(object: any): SimpleWithMap_LongLookupEntry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: SimpleWithMap_LongLookupEntry): unknown { @@ -2097,8 +2106,8 @@ export const SimpleWithMap_BoolLookupEntry = { fromJSON(object: any): SimpleWithMap_BoolLookupEntry { return { - key: isSet(object.key) ? Boolean(object.key) : false, - value: isSet(object.value) ? Number(object.value) : 0, + key: isSet(object.key) ? globalThis.Boolean(object.key) : false, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, }; }, @@ -2254,7 +2263,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromJSON(object: any): SimpleWithSnakeCaseMap_EntitiesByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -2415,7 +2424,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { fromJSON(object: any): SimpleWithMapOfEnums_EnumsByIdEntry { return { - key: isSet(object.key) ? Number(object.key) : 0, + key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? stateEnumFromJSON(object.value) : 0, }; }, @@ -2482,7 +2491,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { input: isSet(object.input) ? String(object.input) : "" }; + return { input: isSet(object.input) ? globalThis.String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -2539,7 +2548,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { output: isSet(object.output) ? String(object.output) : "" }; + return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -2720,18 +2729,18 @@ export const Numbers = { fromJSON(object: any): Numbers { return { - double: isSet(object.double) ? Number(object.double) : 0, - float: isSet(object.float) ? Number(object.float) : 0, - int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? Number(object.int64) : 0, - uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? Number(object.uint64) : 0, - sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? Number(object.sint64) : 0, - fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? Number(object.fixed64) : 0, - sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? Number(object.sfixed64) : 0, + double: isSet(object.double) ? globalThis.Number(object.double) : 0, + float: isSet(object.float) ? globalThis.Number(object.float) : 0, + int32: isSet(object.int32) ? globalThis.Number(object.int32) : 0, + int64: isSet(object.int64) ? globalThis.Number(object.int64) : 0, + uint32: isSet(object.uint32) ? globalThis.Number(object.uint32) : 0, + uint64: isSet(object.uint64) ? globalThis.Number(object.uint64) : 0, + sint32: isSet(object.sint32) ? globalThis.Number(object.sint32) : 0, + sint64: isSet(object.sint64) ? globalThis.Number(object.sint64) : 0, + fixed32: isSet(object.fixed32) ? globalThis.Number(object.fixed32) : 0, + fixed64: isSet(object.fixed64) ? globalThis.Number(object.fixed64) : 0, + sfixed32: isSet(object.sfixed32) ? globalThis.Number(object.sfixed32) : 0, + sfixed64: isSet(object.sfixed64) ? globalThis.Number(object.sfixed64) : 0, }; }, @@ -2902,8 +2911,8 @@ export const SimpleButOptional = { fromJSON(object: any): SimpleButOptional { return { - name: isSet(object.name) ? String(object.name) : undefined, - age: isSet(object.age) ? Number(object.age) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + age: isSet(object.age) ? globalThis.Number(object.age) : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : undefined, @@ -3053,7 +3062,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only-type-registry/bar/bar.ts b/integration/static-only-type-registry/bar/bar.ts index 894ddc806..7e754efaf 100644 --- a/integration/static-only-type-registry/bar/bar.ts +++ b/integration/static-only-type-registry/bar/bar.ts @@ -73,7 +73,8 @@ messageTypeRegistry.set(Bar.$type, Bar); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only-type-registry/foo.ts b/integration/static-only-type-registry/foo.ts index 4ef8ab393..6941ffc8b 100644 --- a/integration/static-only-type-registry/foo.ts +++ b/integration/static-only-type-registry/foo.ts @@ -204,7 +204,8 @@ messageTypeRegistry.set(WithStruct.$type, WithStruct); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only-type-registry/google/protobuf/struct.ts b/integration/static-only-type-registry/google/protobuf/struct.ts index 291c5d8c7..ca3db4fc0 100644 --- a/integration/static-only-type-registry/google/protobuf/struct.ts +++ b/integration/static-only-type-registry/google/protobuf/struct.ts @@ -256,7 +256,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -380,9 +383,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -543,7 +546,8 @@ messageTypeRegistry.set(ListValue.$type, ListValue); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only-type-registry/google/protobuf/timestamp.ts b/integration/static-only-type-registry/google/protobuf/timestamp.ts index 6d43d66cb..bdda2d12c 100644 --- a/integration/static-only-type-registry/google/protobuf/timestamp.ts +++ b/integration/static-only-type-registry/google/protobuf/timestamp.ts @@ -161,8 +161,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -193,7 +193,8 @@ messageTypeRegistry.set(Timestamp.$type, Timestamp); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only-type-registry/typeRegistry.ts b/integration/static-only-type-registry/typeRegistry.ts index bd3a5c2eb..fc7dc8d52 100644 --- a/integration/static-only-type-registry/typeRegistry.ts +++ b/integration/static-only-type-registry/typeRegistry.ts @@ -16,6 +16,7 @@ export const messageTypeRegistry = new Map(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only/bar/bar.ts b/integration/static-only/bar/bar.ts index 3d6b35cec..589957161 100644 --- a/integration/static-only/bar/bar.ts +++ b/integration/static-only/bar/bar.ts @@ -70,7 +70,8 @@ export const Bar = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only/foo.ts b/integration/static-only/foo.ts index 00bda351d..fc9400375 100644 --- a/integration/static-only/foo.ts +++ b/integration/static-only/foo.ts @@ -197,7 +197,8 @@ export const WithStruct = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only/google/protobuf/struct.ts b/integration/static-only/google/protobuf/struct.ts index 5e430399a..404116da3 100644 --- a/integration/static-only/google/protobuf/struct.ts +++ b/integration/static-only/google/protobuf/struct.ts @@ -253,7 +253,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -375,9 +378,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -534,7 +537,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/static-only/google/protobuf/timestamp.ts b/integration/static-only/google/protobuf/timestamp.ts index e2c971479..7425845d4 100644 --- a/integration/static-only/google/protobuf/timestamp.ts +++ b/integration/static-only/google/protobuf/timestamp.ts @@ -160,8 +160,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -190,7 +190,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/struct/google/protobuf/struct.ts b/integration/struct/google/protobuf/struct.ts index 1fbd240e3..3a8e3f4b9 100644 --- a/integration/struct/google/protobuf/struct.ts +++ b/integration/struct/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/struct/struct.ts b/integration/struct/struct.ts index ee5561019..d2886662a 100644 --- a/integration/struct/struct.ts +++ b/integration/struct/struct.ts @@ -68,7 +68,8 @@ export const StructMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/type-annotations/bar/bar.ts b/integration/type-annotations/bar/bar.ts index 02d25f42d..561a9bf72 100644 --- a/integration/type-annotations/bar/bar.ts +++ b/integration/type-annotations/bar/bar.ts @@ -71,7 +71,8 @@ export const Bar = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-annotations/foo.ts b/integration/type-annotations/foo.ts index cd610b9d7..ef4e39ae6 100644 --- a/integration/type-annotations/foo.ts +++ b/integration/type-annotations/foo.ts @@ -200,7 +200,8 @@ export const WithStruct = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-annotations/google/protobuf/struct.ts b/integration/type-annotations/google/protobuf/struct.ts index 3a20c5d74..3679b516c 100644 --- a/integration/type-annotations/google/protobuf/struct.ts +++ b/integration/type-annotations/google/protobuf/struct.ts @@ -263,7 +263,7 @@ export const Struct_FieldsEntry = { fromJSON(object: any): Struct_FieldsEntry { return { $type: Struct_FieldsEntry.$type, - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object?.value) ? object.value : undefined, }; }, @@ -389,9 +389,9 @@ export const Value = { return { $type: Value.$type, nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -548,7 +548,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-annotations/google/protobuf/timestamp.ts b/integration/type-annotations/google/protobuf/timestamp.ts index 73cdf09d5..36962d3ce 100644 --- a/integration/type-annotations/google/protobuf/timestamp.ts +++ b/integration/type-annotations/google/protobuf/timestamp.ts @@ -162,8 +162,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { $type: Timestamp.$type, - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -192,7 +192,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-registry/bar/bar.ts b/integration/type-registry/bar/bar.ts index cf48b0f00..7bc8e907c 100644 --- a/integration/type-registry/bar/bar.ts +++ b/integration/type-registry/bar/bar.ts @@ -74,7 +74,8 @@ messageTypeRegistry.set(Bar.$type, Bar); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-registry/foo.ts b/integration/type-registry/foo.ts index b13abaa86..619415d64 100644 --- a/integration/type-registry/foo.ts +++ b/integration/type-registry/foo.ts @@ -207,7 +207,8 @@ messageTypeRegistry.set(WithStruct.$type, WithStruct); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-registry/google/protobuf/struct.ts b/integration/type-registry/google/protobuf/struct.ts index 9f168d4e0..9c6151278 100644 --- a/integration/type-registry/google/protobuf/struct.ts +++ b/integration/type-registry/google/protobuf/struct.ts @@ -266,7 +266,7 @@ export const Struct_FieldsEntry = { fromJSON(object: any): Struct_FieldsEntry { return { $type: Struct_FieldsEntry.$type, - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object?.value) ? object.value : undefined, }; }, @@ -394,9 +394,9 @@ export const Value = { return { $type: Value.$type, nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -557,7 +557,8 @@ messageTypeRegistry.set(ListValue.$type, ListValue); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 5176dbb6b..c23ac18ef 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -163,8 +163,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { $type: Timestamp.$type, - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -195,7 +195,8 @@ messageTypeRegistry.set(Timestamp.$type, Timestamp); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/type-registry/typeRegistry.ts b/integration/type-registry/typeRegistry.ts index 795709565..f824e4d15 100644 --- a/integration/type-registry/typeRegistry.ts +++ b/integration/type-registry/typeRegistry.ts @@ -16,6 +16,7 @@ export const messageTypeRegistry = new Map(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/types-with-underscores/file.ts b/integration/types-with-underscores/file.ts index 8354311e6..ba017073c 100644 --- a/integration/types-with-underscores/file.ts +++ b/integration/types-with-underscores/file.ts @@ -113,7 +113,8 @@ export const FooBar = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-false/google/protobuf/timestamp.ts b/integration/use-date-false/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/use-date-false/google/protobuf/timestamp.ts +++ b/integration/use-date-false/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-false/metadata.ts b/integration/use-date-false/metadata.ts index ef34a58df..fd39acde6 100644 --- a/integration/use-date-false/metadata.ts +++ b/integration/use-date-false/metadata.ts @@ -70,7 +70,8 @@ export const Metadata = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-string/use-date-string.ts b/integration/use-date-string/use-date-string.ts index 63bea1fb0..d20076369 100644 --- a/integration/use-date-string/use-date-string.ts +++ b/integration/use-date-string/use-date-string.ts @@ -97,7 +97,7 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", timestamp: isSet(object.timestamp) ? globalThis.String(object.timestamp) : undefined, repeatedTimestamp: globalThis.Array.isArray(object?.repeatedTimestamp) ? object.repeatedTimestamp.map((e: any) => globalThis.String(e)) @@ -207,7 +207,7 @@ export const Todo_MapOfTimestampsEntry = { fromJSON(object: any): Todo_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? globalThis.String(object.value) : undefined, }; }, @@ -237,7 +237,8 @@ export const Todo_MapOfTimestampsEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-true/google/protobuf/empty.ts b/integration/use-date-true/google/protobuf/empty.ts index 5f012de45..b43712c5b 100644 --- a/integration/use-date-true/google/protobuf/empty.ts +++ b/integration/use-date-true/google/protobuf/empty.ts @@ -63,7 +63,8 @@ export const Empty = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index e1de58c47..a5d2b4050 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -98,7 +98,7 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, repeatedTimestamp: globalThis.Array.isArray(object?.repeatedTimestamp) ? object.repeatedTimestamp.map((e: any) => fromJsonTimestamp(e)) @@ -208,7 +208,7 @@ export const Todo_MapOfTimestampsEntry = { fromJSON(object: any): Todo_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -278,7 +278,8 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-exact-types-false/foo.ts b/integration/use-exact-types-false/foo.ts index 80cee2f5a..740d23115 100644 --- a/integration/use-exact-types-false/foo.ts +++ b/integration/use-exact-types-false/foo.ts @@ -54,7 +54,10 @@ export const Foo = { }, fromJSON(object: any): Foo { - return { bar: isSet(object.bar) ? String(object.bar) : "", baz: isSet(object.baz) ? String(object.baz) : "" }; + return { + bar: isSet(object.bar) ? globalThis.String(object.bar) : "", + baz: isSet(object.baz) ? globalThis.String(object.baz) : "", + }; }, toJSON(message: Foo): unknown { @@ -82,7 +85,8 @@ export const Foo = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-map-type/google/protobuf/struct.ts b/integration/use-map-type/google/protobuf/struct.ts index 19f8928c2..4309baf71 100644 --- a/integration/use-map-type/google/protobuf/struct.ts +++ b/integration/use-map-type/google/protobuf/struct.ts @@ -244,7 +244,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -364,9 +367,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -521,7 +524,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-map-type/google/protobuf/timestamp.ts b/integration/use-map-type/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/use-map-type/google/protobuf/timestamp.ts +++ b/integration/use-map-type/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-map-type/use-map-type.ts b/integration/use-map-type/use-map-type.ts index 20e3d8b52..d577b240f 100644 --- a/integration/use-map-type/use-map-type.ts +++ b/integration/use-map-type/use-map-type.ts @@ -80,7 +80,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { id: isSet(object.id) ? Number(object.id) : 0 }; + return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -300,7 +300,7 @@ export const Maps = { const m = new Map(); (object.int32ToInt32 as Map ?? new Map()).forEach((value, key) => { if (value !== undefined) { - m.set(key, Number(value)); + m.set(key, globalThis.Number(value)); } }); return m; @@ -318,7 +318,7 @@ export const Maps = { const m = new Map(); (object.int64ToInt64 as Map ?? new Map()).forEach((value, key) => { if (value !== undefined) { - m.set(key, Number(value)); + m.set(key, globalThis.Number(value)); } }); return m; @@ -384,7 +384,7 @@ export const Maps_StrToEntityEntry = { fromJSON(object: any): Maps_StrToEntityEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -459,7 +459,10 @@ export const Maps_Int32ToInt32Entry = { }, fromJSON(object: any): Maps_Int32ToInt32Entry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: Maps_Int32ToInt32Entry): unknown { @@ -531,7 +534,7 @@ export const Maps_StringToBytesEntry = { fromJSON(object: any): Maps_StringToBytesEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0), }; }, @@ -604,7 +607,10 @@ export const Maps_Int64ToInt64Entry = { }, fromJSON(object: any): Maps_Int64ToInt64Entry { - return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + }; }, toJSON(message: Maps_Int64ToInt64Entry): unknown { @@ -676,7 +682,7 @@ export const Maps_MapOfTimestampsEntry = { fromJSON(object: any): Maps_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -731,7 +737,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-numeric-enum-json/google/protobuf/struct.ts b/integration/use-numeric-enum-json/google/protobuf/struct.ts index 80e632542..ab56a6b9b 100644 --- a/integration/use-numeric-enum-json/google/protobuf/struct.ts +++ b/integration/use-numeric-enum-json/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-numeric-enum-json/simple.ts b/integration/use-numeric-enum-json/simple.ts index b4780779e..a4931475e 100644 --- a/integration/use-numeric-enum-json/simple.ts +++ b/integration/use-numeric-enum-json/simple.ts @@ -148,7 +148,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : "", + name: isSet(object.name) ? globalThis.String(object.name) : "", state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, states: globalThis.Array.isArray(object?.states) ? object.states.map((e: any) => stateEnumFromJSON(e)) : [], nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : 0, @@ -256,7 +256,7 @@ export const Simple_StateMapEntry = { fromJSON(object: any): Simple_StateMapEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? stateEnumFromJSON(object.value) : 0, }; }, @@ -286,7 +286,8 @@ export const Simple_StateMapEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-objectid-true-external-import/objectid/objectid.ts b/integration/use-objectid-true-external-import/objectid/objectid.ts index 944ab5791..be7d888c6 100644 --- a/integration/use-objectid-true-external-import/objectid/objectid.ts +++ b/integration/use-objectid-true-external-import/objectid/objectid.ts @@ -43,7 +43,7 @@ export const ObjectId = { }, fromJSON(object: any): ObjectId { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: ObjectId): unknown { @@ -67,7 +67,8 @@ export const ObjectId = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-objectid-true-external-import/use-objectid-true.ts b/integration/use-objectid-true-external-import/use-objectid-true.ts index 2a7e9d170..d33489596 100644 --- a/integration/use-objectid-true-external-import/use-objectid-true.ts +++ b/integration/use-objectid-true-external-import/use-objectid-true.ts @@ -98,7 +98,7 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : "", + id: isSet(object.id) ? globalThis.String(object.id) : "", oid: isSet(object.oid) ? fromJsonObjectId(object.oid) : undefined, repeatedOid: globalThis.Array.isArray(object?.repeatedOid) ? object.repeatedOid.map((e: any) => fromJsonObjectId(e)) @@ -210,7 +210,7 @@ export const Todo_MapOfOidsEntry = { fromJSON(object: any): Todo_MapOfOidsEntry { return { - key: isSet(object.key) ? String(object.key) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? fromJsonObjectId(object.value) : undefined, }; }, @@ -242,7 +242,8 @@ export const Todo_MapOfOidsEntry = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-optionals-all/google/protobuf/timestamp.ts b/integration/use-optionals-all/google/protobuf/timestamp.ts index a38f36433..48f0125bb 100644 --- a/integration/use-optionals-all/google/protobuf/timestamp.ts +++ b/integration/use-optionals-all/google/protobuf/timestamp.ts @@ -160,8 +160,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -190,7 +190,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-optionals-all/test.ts b/integration/use-optionals-all/test.ts index d9cef1d43..831a7a4ec 100644 --- a/integration/use-optionals-all/test.ts +++ b/integration/use-optionals-all/test.ts @@ -424,28 +424,30 @@ export const OptionalsTest = { fromJSON(object: any): OptionalsTest { return { - id: isSet(object.id) ? Number(object.id) : 0, + id: isSet(object.id) ? globalThis.Number(object.id) : 0, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, - long: isSet(object.long) ? Number(object.long) : 0, - truth: isSet(object.truth) ? Boolean(object.truth) : false, - description: isSet(object.description) ? String(object.description) : "", + long: isSet(object.long) ? globalThis.Number(object.long) : 0, + truth: isSet(object.truth) ? globalThis.Boolean(object.truth) : false, + description: isSet(object.description) ? globalThis.String(object.description) : "", data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => Number(e)) : [], + repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => globalThis.Number(e)) : [], repChild: globalThis.Array.isArray(object?.repChild) ? object.repChild.map((e: any) => Child.fromJSON(e)) : [], repState: globalThis.Array.isArray(object?.repState) ? object.repState.map((e: any) => stateEnumFromJSON(e)) : [], - repLong: globalThis.Array.isArray(object?.repLong) ? object.repLong.map((e: any) => Number(e)) : [], - repTruth: globalThis.Array.isArray(object?.repTruth) ? object.repTruth.map((e: any) => Boolean(e)) : [], + repLong: globalThis.Array.isArray(object?.repLong) ? object.repLong.map((e: any) => globalThis.Number(e)) : [], + repTruth: globalThis.Array.isArray(object?.repTruth) + ? object.repTruth.map((e: any) => globalThis.Boolean(e)) + : [], repDescription: globalThis.Array.isArray(object?.repDescription) - ? object.repDescription.map((e: any) => String(e)) + ? object.repDescription.map((e: any) => globalThis.String(e)) : [], repData: globalThis.Array.isArray(object?.repData) ? object.repData.map((e: any) => bytesFromBase64(e)) : [], - optId: isSet(object.optId) ? Number(object.optId) : undefined, + optId: isSet(object.optId) ? globalThis.Number(object.optId) : undefined, optChild: isSet(object.optChild) ? Child.fromJSON(object.optChild) : undefined, optState: isSet(object.optState) ? stateEnumFromJSON(object.optState) : undefined, - optLong: isSet(object.optLong) ? Number(object.optLong) : undefined, - optTruth: isSet(object.optTruth) ? Boolean(object.optTruth) : undefined, - optDescription: isSet(object.optDescription) ? String(object.optDescription) : undefined, + optLong: isSet(object.optLong) ? globalThis.Number(object.optLong) : undefined, + optTruth: isSet(object.optTruth) ? globalThis.Boolean(object.optTruth) : undefined, + optDescription: isSet(object.optDescription) ? globalThis.String(object.optDescription) : undefined, optData: isSet(object.optData) ? bytesFromBase64(object.optData) : undefined, translations: isObject(object.translations) ? Object.entries(object.translations).reduce<{ [key: string]: string }>((acc, [key, value]) => { @@ -568,7 +570,7 @@ export const OptionalsTest = { message.translations = Object.entries(object.translations ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, @@ -625,7 +627,10 @@ export const OptionalsTest_TranslationsEntry = { }, fromJSON(object: any): OptionalsTest_TranslationsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: OptionalsTest_TranslationsEntry): unknown { @@ -723,7 +728,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-optionals-no-undefined/test.ts b/integration/use-optionals-no-undefined/test.ts index 3a41552d1..3384fc3a7 100644 --- a/integration/use-optionals-no-undefined/test.ts +++ b/integration/use-optionals-no-undefined/test.ts @@ -424,34 +424,38 @@ export const OptionalsTest = { fromJSON(object: any): OptionalsTest { return { - id: isSet(object.id) ? Number(object.id) : undefined, + id: isSet(object.id) ? globalThis.Number(object.id) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, state: isSet(object.state) ? stateEnumFromJSON(object.state) : undefined, - long: isSet(object.long) ? Number(object.long) : undefined, - truth: isSet(object.truth) ? Boolean(object.truth) : undefined, - description: isSet(object.description) ? String(object.description) : undefined, + long: isSet(object.long) ? globalThis.Number(object.long) : undefined, + truth: isSet(object.truth) ? globalThis.Boolean(object.truth) : undefined, + description: isSet(object.description) ? globalThis.String(object.description) : undefined, data: isSet(object.data) ? bytesFromBase64(object.data) : undefined, - repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => Number(e)) : undefined, + repId: globalThis.Array.isArray(object?.repId) ? object.repId.map((e: any) => globalThis.Number(e)) : undefined, repChild: globalThis.Array.isArray(object?.repChild) ? object.repChild.map((e: any) => Child.fromJSON(e)) : undefined, repState: globalThis.Array.isArray(object?.repState) ? object.repState.map((e: any) => stateEnumFromJSON(e)) : undefined, - repLong: globalThis.Array.isArray(object?.repLong) ? object.repLong.map((e: any) => Number(e)) : undefined, - repTruth: globalThis.Array.isArray(object?.repTruth) ? object.repTruth.map((e: any) => Boolean(e)) : undefined, + repLong: globalThis.Array.isArray(object?.repLong) + ? object.repLong.map((e: any) => globalThis.Number(e)) + : undefined, + repTruth: globalThis.Array.isArray(object?.repTruth) + ? object.repTruth.map((e: any) => globalThis.Boolean(e)) + : undefined, repDescription: globalThis.Array.isArray(object?.repDescription) - ? object.repDescription.map((e: any) => String(e)) + ? object.repDescription.map((e: any) => globalThis.String(e)) : undefined, repData: globalThis.Array.isArray(object?.repData) ? object.repData.map((e: any) => bytesFromBase64(e)) : undefined, - optId: isSet(object.optId) ? Number(object.optId) : undefined, + optId: isSet(object.optId) ? globalThis.Number(object.optId) : undefined, optChild: isSet(object.optChild) ? Child.fromJSON(object.optChild) : undefined, optState: isSet(object.optState) ? stateEnumFromJSON(object.optState) : undefined, - optLong: isSet(object.optLong) ? Number(object.optLong) : undefined, - optTruth: isSet(object.optTruth) ? Boolean(object.optTruth) : undefined, - optDescription: isSet(object.optDescription) ? String(object.optDescription) : undefined, + optLong: isSet(object.optLong) ? globalThis.Number(object.optLong) : undefined, + optTruth: isSet(object.optTruth) ? globalThis.Boolean(object.optTruth) : undefined, + optDescription: isSet(object.optDescription) ? globalThis.String(object.optDescription) : undefined, optData: isSet(object.optData) ? bytesFromBase64(object.optData) : undefined, translations: isObject(object.translations) ? Object.entries(object.translations).reduce<{ [key: string]: string }>((acc, [key, value]) => { @@ -571,7 +575,7 @@ export const OptionalsTest = { ? undefined : Object.entries(object.translations ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => { if (value !== undefined) { - acc[key] = String(value); + acc[key] = globalThis.String(value); } return acc; }, {}); @@ -625,7 +629,10 @@ export const OptionalsTest_TranslationsEntry = { }, fromJSON(object: any): OptionalsTest_TranslationsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + }; }, toJSON(message: OptionalsTest_TranslationsEntry): unknown { @@ -723,7 +730,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/use-readonly-types/google/protobuf/field_mask.ts b/integration/use-readonly-types/google/protobuf/field_mask.ts index 878325a12..25af6a6bd 100644 --- a/integration/use-readonly-types/google/protobuf/field_mask.ts +++ b/integration/use-readonly-types/google/protobuf/field_mask.ts @@ -280,7 +280,8 @@ export const FieldMask = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { readonly $case: string } ? { [K in keyof Omit]?: DeepPartial } & { readonly $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } diff --git a/integration/use-readonly-types/google/protobuf/struct.ts b/integration/use-readonly-types/google/protobuf/struct.ts index 50017f93e..93299eb71 100644 --- a/integration/use-readonly-types/google/protobuf/struct.ts +++ b/integration/use-readonly-types/google/protobuf/struct.ts @@ -235,7 +235,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -352,11 +355,11 @@ export const Value = { kind: isSet(object.nullValue) ? { $case: "nullValue", nullValue: nullValueFromJSON(object.nullValue) } : isSet(object.numberValue) - ? { $case: "numberValue", numberValue: Number(object.numberValue) } + ? { $case: "numberValue", numberValue: globalThis.Number(object.numberValue) } : isSet(object.stringValue) - ? { $case: "stringValue", stringValue: String(object.stringValue) } + ? { $case: "stringValue", stringValue: globalThis.String(object.stringValue) } : isSet(object.boolValue) - ? { $case: "boolValue", boolValue: Boolean(object.boolValue) } + ? { $case: "boolValue", boolValue: globalThis.Boolean(object.boolValue) } : isSet(object.structValue) ? { $case: "structValue", structValue: object.structValue } : isSet(object.listValue) @@ -539,7 +542,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { readonly $case: string } ? { [K in keyof Omit]?: DeepPartial } & { readonly $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } diff --git a/integration/use-readonly-types/use-readonly-types.ts b/integration/use-readonly-types/use-readonly-types.ts index 5a9b60a45..e939aa92b 100644 --- a/integration/use-readonly-types/use-readonly-types.ts +++ b/integration/use-readonly-types/use-readonly-types.ts @@ -199,22 +199,24 @@ export const Entity = { fromJSON(object: any): Entity { return { - intVal: isSet(object.intVal) ? Number(object.intVal) : 0, - stringVal: isSet(object.stringVal) ? String(object.stringVal) : "", - intArray: globalThis.Array.isArray(object?.intArray) ? object.intArray.map((e: any) => Number(e)) : [], - stringArray: globalThis.Array.isArray(object?.stringArray) ? object.stringArray.map((e: any) => String(e)) : [], + intVal: isSet(object.intVal) ? globalThis.Number(object.intVal) : 0, + stringVal: isSet(object.stringVal) ? globalThis.String(object.stringVal) : "", + intArray: globalThis.Array.isArray(object?.intArray) ? object.intArray.map((e: any) => globalThis.Number(e)) : [], + stringArray: globalThis.Array.isArray(object?.stringArray) + ? object.stringArray.map((e: any) => globalThis.String(e)) + : [], subEntity: isSet(object.subEntity) ? SubEntity.fromJSON(object.subEntity) : undefined, subEntityArray: globalThis.Array.isArray(object?.subEntityArray) ? object.subEntityArray.map((e: any) => SubEntity.fromJSON(e)) : [], - optionalIntVal: isSet(object.optionalIntVal) ? Number(object.optionalIntVal) : undefined, + optionalIntVal: isSet(object.optionalIntVal) ? globalThis.Number(object.optionalIntVal) : undefined, fieldMask: isSet(object.fieldMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.fieldMask)) : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, oneOfValue: isSet(object.theStringValue) - ? { $case: "theStringValue", theStringValue: String(object.theStringValue) } + ? { $case: "theStringValue", theStringValue: globalThis.String(object.theStringValue) } : isSet(object.theIntValue) - ? { $case: "theIntValue", theIntValue: Number(object.theIntValue) } + ? { $case: "theIntValue", theIntValue: globalThis.Number(object.theIntValue) } : undefined, }; }, @@ -331,7 +333,7 @@ export const SubEntity = { }, fromJSON(object: any): SubEntity { - return { subVal: isSet(object.subVal) ? Number(object.subVal) : 0 }; + return { subVal: isSet(object.subVal) ? globalThis.Number(object.subVal) : 0 }; }, toJSON(message: SubEntity): unknown { @@ -355,7 +357,8 @@ export const SubEntity = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends { readonly $case: string } ? { [K in keyof Omit]?: DeepPartial } & { readonly $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } diff --git a/integration/value/google/protobuf/struct.ts b/integration/value/google/protobuf/struct.ts index 1fbd240e3..3a8e3f4b9 100644 --- a/integration/value/google/protobuf/struct.ts +++ b/integration/value/google/protobuf/struct.ts @@ -249,7 +249,10 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + return { + key: isSet(object.key) ? globalThis.String(object.key) : "", + value: isSet(object?.value) ? object.value : undefined, + }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -369,9 +372,9 @@ export const Value = { fromJSON(object: any): Value { return { nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, - numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, - stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined, structValue: isObject(object.structValue) ? object.structValue : undefined, listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined, }; @@ -526,7 +529,8 @@ export const ListValue = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/value/google/protobuf/wrappers.ts b/integration/value/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/value/google/protobuf/wrappers.ts +++ b/integration/value/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/value/value.ts b/integration/value/value.ts index 511631d83..73ab6a13d 100644 --- a/integration/value/value.ts +++ b/integration/value/value.ts @@ -137,7 +137,8 @@ export const ValueMessage = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/vector-tile/vector_tile.ts b/integration/vector-tile/vector_tile.ts index 5bf5d6b11..383bd9bb9 100644 --- a/integration/vector-tile/vector_tile.ts +++ b/integration/vector-tile/vector_tile.ts @@ -235,13 +235,13 @@ export const Tile_Value = { fromJSON(object: any): Tile_Value { return { - stringValue: isSet(object.stringValue) ? String(object.stringValue) : "", - floatValue: isSet(object.floatValue) ? Number(object.floatValue) : 0, - doubleValue: isSet(object.doubleValue) ? Number(object.doubleValue) : 0, - intValue: isSet(object.intValue) ? Number(object.intValue) : 0, - uintValue: isSet(object.uintValue) ? Number(object.uintValue) : 0, - sintValue: isSet(object.sintValue) ? Number(object.sintValue) : 0, - boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : false, + stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : "", + floatValue: isSet(object.floatValue) ? globalThis.Number(object.floatValue) : 0, + doubleValue: isSet(object.doubleValue) ? globalThis.Number(object.doubleValue) : 0, + intValue: isSet(object.intValue) ? globalThis.Number(object.intValue) : 0, + uintValue: isSet(object.uintValue) ? globalThis.Number(object.uintValue) : 0, + sintValue: isSet(object.sintValue) ? globalThis.Number(object.sintValue) : 0, + boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : false, }; }, @@ -378,10 +378,10 @@ export const Tile_Feature = { fromJSON(object: any): Tile_Feature { return { - id: isSet(object.id) ? Number(object.id) : 0, - tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e: any) => Number(e)) : [], + id: isSet(object.id) ? globalThis.Number(object.id) : 0, + tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e: any) => globalThis.Number(e)) : [], type: isSet(object.type) ? tile_GeomTypeFromJSON(object.type) : 0, - geometry: globalThis.Array.isArray(object?.geometry) ? object.geometry.map((e: any) => Number(e)) : [], + geometry: globalThis.Array.isArray(object?.geometry) ? object.geometry.map((e: any) => globalThis.Number(e)) : [], }; }, @@ -502,14 +502,14 @@ export const Tile_Layer = { fromJSON(object: any): Tile_Layer { return { - version: isSet(object.version) ? Number(object.version) : 0, - name: isSet(object.name) ? String(object.name) : "", + version: isSet(object.version) ? globalThis.Number(object.version) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : "", features: globalThis.Array.isArray(object?.features) ? object.features.map((e: any) => Tile_Feature.fromJSON(e)) : [], - keys: globalThis.Array.isArray(object?.keys) ? object.keys.map((e: any) => String(e)) : [], + keys: globalThis.Array.isArray(object?.keys) ? object.keys.map((e: any) => globalThis.String(e)) : [], values: globalThis.Array.isArray(object?.values) ? object.values.map((e: any) => Tile_Value.fromJSON(e)) : [], - extent: isSet(object.extent) ? Number(object.extent) : 0, + extent: isSet(object.extent) ? globalThis.Number(object.extent) : 0, }; }, @@ -554,7 +554,8 @@ export const Tile_Layer = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/wrappers-regression/google/protobuf/empty.ts b/integration/wrappers-regression/google/protobuf/empty.ts index 5f012de45..b43712c5b 100644 --- a/integration/wrappers-regression/google/protobuf/empty.ts +++ b/integration/wrappers-regression/google/protobuf/empty.ts @@ -63,7 +63,8 @@ export const Empty = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/wrappers-regression/google/protobuf/timestamp.ts b/integration/wrappers-regression/google/protobuf/timestamp.ts index 7b5fb6231..0cf501b86 100644 --- a/integration/wrappers-regression/google/protobuf/timestamp.ts +++ b/integration/wrappers-regression/google/protobuf/timestamp.ts @@ -158,8 +158,8 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? Number(object.seconds) : 0, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, @@ -188,7 +188,8 @@ export const Timestamp = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/integration/wrappers-regression/google/protobuf/wrappers.ts b/integration/wrappers-regression/google/protobuf/wrappers.ts index 98a564806..6aa1a51cc 100644 --- a/integration/wrappers-regression/google/protobuf/wrappers.ts +++ b/integration/wrappers-regression/google/protobuf/wrappers.ts @@ -130,7 +130,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -187,7 +187,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -244,7 +244,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -301,7 +301,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -358,7 +358,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -415,7 +415,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { value: isSet(object.value) ? Number(object.value) : 0 }; + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -472,7 +472,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { value: isSet(object.value) ? Boolean(object.value) : false }; + return { value: isSet(object.value) ? globalThis.Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -529,7 +529,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { value: isSet(object.value) ? String(object.value) : "" }; + return { value: isSet(object.value) ? globalThis.String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -635,7 +635,8 @@ function base64FromBytes(arr: Uint8Array): string { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; diff --git a/src/main.ts b/src/main.ts index 86209fb3f..9033b2806 100644 --- a/src/main.ts +++ b/src/main.ts @@ -610,8 +610,8 @@ function makeDeepPartial(options: Options, longs: ReturnType = T extends ${Builtin} ? T ${maybeLong} - : T extends Array - ? Array> + : T extends globalThis.Array + ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray>${oneofCase} : T extends {} @@ -1756,7 +1756,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, return code`BigInt(${from})`; } else { const cstr = capitalize(basicTypeName(ctx, field, { keepValueType: true }).toCodeString([])); - return code`${cstr}(${from})`; + return code`${utils.globalThis}.${cstr}(${from})`; } } else if (isObjectId(field) && options.useMongoObjectId) { return code`${utils.fromJsonObjectId}(${from})`; @@ -2161,7 +2161,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri return code`BigInt(${from} as string | number | bigint | boolean)`; } else { const cstr = capitalize(valueType.toCodeString([])); - return code`${cstr}(${from})`; + return code`${utils.globalThis}.${cstr}(${from})`; } } else if (isAnyValueType(valueField)) { return code`${from}`;