Skip to content

Commit

Permalink
fix: noImplicitReturns error in Value.unwrap (#436)
Browse files Browse the repository at this point in the history
* fix noImplicitReturns error in Value.unwrap

Fixes #432

* Force shell script LF line-endings

* Update generated struct.ts files

* Ensure parameters.txt are checked out with LF line endings

* Ensure protoc-gen-dump is checked out with LF line endings
  • Loading branch information
boukeversteegh authored Dec 8, 2021
1 parent 488e564 commit 2d7a5d0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.sh text eol=lf
parameters.txt text eol=lf
protoc-gen-dump text eol=lf
13 changes: 7 additions & 6 deletions integration/grpc-js/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,20 @@ export const Value = {
},

unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
if (message.stringValue !== undefined) {
if (message?.stringValue !== undefined) {
return message.stringValue;
} else if (message.numberValue !== undefined) {
} else if (message?.numberValue !== undefined) {
return message.numberValue;
} else if (message.boolValue !== undefined) {
} else if (message?.boolValue !== undefined) {
return message.boolValue;
} else if (message.structValue !== undefined) {
} else if (message?.structValue !== undefined) {
return message.structValue;
} else if (message.listValue !== undefined) {
} else if (message?.listValue !== undefined) {
return message.listValue;
} else if (message.nullValue !== undefined) {
} else if (message?.nullValue !== undefined) {
return null;
}
return undefined;
},
};

Expand Down
13 changes: 7 additions & 6 deletions integration/simple-string-enums/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,20 @@ export const Value = {
},

unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
if (message.stringValue !== undefined) {
if (message?.stringValue !== undefined) {
return message.stringValue;
} else if (message.numberValue !== undefined) {
} else if (message?.numberValue !== undefined) {
return message.numberValue;
} else if (message.boolValue !== undefined) {
} else if (message?.boolValue !== undefined) {
return message.boolValue;
} else if (message.structValue !== undefined) {
} else if (message?.structValue !== undefined) {
return message.structValue;
} else if (message.listValue !== undefined) {
} else if (message?.listValue !== undefined) {
return message.listValue;
} else if (message.nullValue !== undefined) {
} else if (message?.nullValue !== undefined) {
return null;
}
return undefined;
},
};

Expand Down
13 changes: 7 additions & 6 deletions integration/struct/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,20 @@ export const Value = {
},

unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
if (message.stringValue !== undefined) {
if (message?.stringValue !== undefined) {
return message.stringValue;
} else if (message.numberValue !== undefined) {
} else if (message?.numberValue !== undefined) {
return message.numberValue;
} else if (message.boolValue !== undefined) {
} else if (message?.boolValue !== undefined) {
return message.boolValue;
} else if (message.structValue !== undefined) {
} else if (message?.structValue !== undefined) {
return message.structValue;
} else if (message.listValue !== undefined) {
} else if (message?.listValue !== undefined) {
return message.listValue;
} else if (message.nullValue !== undefined) {
} else if (message?.nullValue !== undefined) {
return null;
}
return undefined;
},
};

Expand Down
13 changes: 7 additions & 6 deletions integration/value/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,20 @@ export const Value = {
},

unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
if (message.stringValue !== undefined) {
if (message?.stringValue !== undefined) {
return message.stringValue;
} else if (message.numberValue !== undefined) {
} else if (message?.numberValue !== undefined) {
return message.numberValue;
} else if (message.boolValue !== undefined) {
} else if (message?.boolValue !== undefined) {
return message.boolValue;
} else if (message.structValue !== undefined) {
} else if (message?.structValue !== undefined) {
return message.structValue;
} else if (message.listValue !== undefined) {
} else if (message?.listValue !== undefined) {
return message.listValue;
} else if (message.nullValue !== undefined) {
} else if (message?.nullValue !== undefined) {
return null;
}
return undefined;
},
};

Expand Down
13 changes: 7 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1370,19 +1370,20 @@ function generateUnwrap(fullProtoTypeName: string): Code[] {

if (isAnyValueTypeName(fullProtoTypeName)) {
chunks.push(code`unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
if (message.stringValue !== undefined) {
if (message?.stringValue !== undefined) {
return message.stringValue;
} else if (message.numberValue !== undefined) {
} else if (message?.numberValue !== undefined) {
return message.numberValue;
} else if (message.boolValue !== undefined) {
} else if (message?.boolValue !== undefined) {
return message.boolValue;
} else if (message.structValue !== undefined) {
} else if (message?.structValue !== undefined) {
return message.structValue;
} else if (message.listValue !== undefined) {
} else if (message?.listValue !== undefined) {
return message.listValue;
} else if (message.nullValue !== undefined) {
} else if (message?.nullValue !== undefined) {
return null;
}
return undefined;
}`);
}

Expand Down

0 comments on commit 2d7a5d0

Please sign in to comment.