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

Fix types of sub-messages in class declaration #1952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,13 @@ function buildFunction(type, functionName, gen, scope) {
push("};");
}

function toJsType(field) {
function toJsType(field, asInterface) {
var type;

if (asInterface === undefined) {
asInterface = true;
}

switch (field.type) {
case "double":
case "float":
Expand Down Expand Up @@ -342,7 +346,7 @@ function toJsType(field) {
break;
default:
if (field.resolve().resolvedType)
type = exportName(field.resolvedType, !(field.resolvedType instanceof protobuf.Enum || config.forceMessage));
type = exportName(field.resolvedType, asInterface && !(field.resolvedType instanceof protobuf.Enum || config.forceMessage));
else
type = "*"; // should not happen
break;
Expand Down Expand Up @@ -393,7 +397,7 @@ function buildType(ref, type) {
var prop = util.safeProp(field.name);
if (config.comments) {
push("");
var jsType = toJsType(field);
var jsType = toJsType(field, false);
if (field.optional && !field.map && !field.repeated && (field.resolvedType instanceof Type || config["null-defaults"]) || field.partOf)
jsType = jsType + "|null|undefined";
pushComment([
Expand Down