From 8aa21268aa5e0f568cb39e99a83b99ccb4084381 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Mon, 27 Mar 2017 21:41:03 +0200 Subject: [PATCH] Fixed: Ensure that fields have been resolved when looking up js types in static target, see #731 --- cli/lib/tsd-jsdoc/README.md | 2 +- cli/targets/static.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/lib/tsd-jsdoc/README.md b/cli/lib/tsd-jsdoc/README.md index 316719e12..beed748fc 100644 --- a/cli/lib/tsd-jsdoc/README.md +++ b/cli/lib/tsd-jsdoc/README.md @@ -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 ------- diff --git a/cli/targets/static.js b/cli/targets/static.js index 7a3dea453..e6844f7bc 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -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);