Skip to content

Commit

Permalink
Fixed: Ensure that fields have been resolved when looking up js types…
Browse files Browse the repository at this point in the history
… in static target, see #731
  • Loading branch information
dcodeIO committed Mar 27, 2017
1 parent e4a6b6f commit 8aa2126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/lib/tsd-jsdoc/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
protobuf.js fork of tsd-jsdoc
=============================

This is a slightly modified and restructured version of [tsd-jsdoc](https://github.com/englercj/tsd-jsdoc) for use with protobuf.js, parked here so we can process issues and pull requests.
This is a modified version of [tsd-jsdoc](https://github.com/englercj/tsd-jsdoc) v1.0.1 for use with protobuf.js, parked here so we can process issues and pull requests. The ultimate goal is to switch back to the a recent version of tsd-jsdoc once it meets our needs.

Options
-------
Expand Down
7 changes: 3 additions & 4 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function toJsType(field) {
type = "Uint8Array";
break;
default:
if (field.resolvedType instanceof Enum)
if (field.resolve().resolvedType instanceof Enum)
type = field.resolvedType.fullName.substring(1); // reference the enum
else if (field.resolvedType instanceof Type)
type = field.resolvedType.fullName.substring(1) + "$Properties"; // reference the interface
Expand All @@ -302,10 +302,9 @@ function buildType(ref, type) {
"@type {Object}"
];
type.fieldsArray.forEach(function(field) {
var jsType = toJsType(field),
prop = util.safeProp(field.name);
var prop = util.safeProp(field.name);
prop = prop.substring(1, prop.charAt(0) === "[" ? prop.length - 1 : prop.length);
typeDef.push("@property {" + jsType + "} " + (field.optional ? "[" + prop + "]" : field.name) + " " + (field.comment || type.name + " " + field.name + "."));
typeDef.push("@property {" + toJsType(field) + "} " + (field.optional ? "[" + prop + "]" : field.name) + " " + (field.comment || type.name + " " + field.name + "."));
});
push("");
pushComment(typeDef);
Expand Down

0 comments on commit 8aa2126

Please sign in to comment.