Permalink
Browse files

Fixed: Ensure that fields have been resolved when looking up js types…

… in static target, see #731
  • Loading branch information...
dcodeIO committed Mar 27, 2017
1 parent e4a6b6f commit 8aa21268aa5e0f568cb39e99a83b99ccb4084381
Showing with 4 additions and 5 deletions.
  1. +1 −1 cli/lib/tsd-jsdoc/README.md
  2. +3 −4 cli/targets/static.js
@@ -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
-------
@@ -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
@@ -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);

0 comments on commit 8aa2126

Please sign in to comment.