Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JOIN-11804] fix: always unwrap message into plain object #37

Merged
merged 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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