Skip to content

Commit

Permalink
Merge pull request #37 from join-com/join-11804
Browse files Browse the repository at this point in the history
[JOIN-11804] fix: always unwrap message into plain object
  • Loading branch information
castarco authored May 6, 2021
2 parents 87bc02a + 10c996e commit 8f28672
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
5 changes: 1 addition & 4 deletions tests/__tests__/generated/Flavors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ export namespace Flavors {
public userId?: UserId

public asInterface(): IUserRequest {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof IUserRequest] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down
15 changes: 3 additions & 12 deletions tests/__tests__/generated/Test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ export namespace Foo {
public title?: string

public asInterface(): INested {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof INested] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down Expand Up @@ -222,10 +219,7 @@ export namespace Foo {
public id?: number

public asInterface(): IRequest {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof IRequest] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down Expand Up @@ -269,10 +263,7 @@ export namespace Foo {
public optionalField?: number

public asInterface(): IRequiredPropertiesTest {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof IRequiredPropertiesTest] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down
5 changes: 1 addition & 4 deletions tests/__tests__/generated/common/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export namespace Common {
public latsName?: string

public asInterface(): IOtherPkgMessage {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof IOtherPkgMessage] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down
5 changes: 1 addition & 4 deletions tests/__tests__/generated/google/protobuf/Timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export namespace GoogleProtobuf {
public nanos?: number

public asInterface(): ITimestamp {
/* eslint-disable @typescript-eslint/no-this-alias */
// tslint:disable-next-line: no-this-assignment
const message = this
/* eslint-enable @typescript-eslint/no-this-alias */
const message = { ...this }
for (const fieldName of Object.keys(message)) {
if (message[fieldName as keyof ITimestamp] == null) {
// We remove the key to avoid problems with code making too many assumptions
Expand Down

0 comments on commit 8f28672

Please sign in to comment.