Skip to content

Commit

Permalink
Respect optional properties when writing interfaces in tsd-jsdoc, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 30, 2016
1 parent 1f18453 commit 7eb3d45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lib/tsd-jsdoc/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ function writeInterface(element) {
writeln("interface ", element.name, " {");
++indent;
element.properties.forEach(function(property) {
writeln(property.name, ": ", getTypeOf(property), ";");
write(property.name);
if (property.optional)
write("?");
writeln(": ", getTypeOf(property), ";");
});
--indent;
writeln("}");
Expand Down
15 changes: 8 additions & 7 deletions types/protobuf.js.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// $> pbts --name protobufjs --out types/protobuf.js.d.ts src
// Generated Fri, 30 Dec 2016 00:51:27 UTC
// Generated Fri, 30 Dec 2016 12:09:31 UTC

declare module "protobufjs" {

/**
Expand Down Expand Up @@ -131,11 +132,11 @@ declare module "protobufjs" {
* @property {boolean} [defaults=false] Also sets default values on the resulting object
*/
interface JSONConversionOptions {
fieldsOnly: boolean;
longs: any;
enums: any;
bytes: any;
defaults: boolean;
fieldsOnly?: boolean;
longs?: any;
enums?: any;
bytes?: any;
defaults?: boolean;
}

/**
Expand All @@ -145,7 +146,7 @@ declare module "protobufjs" {
* @property {boolean} [fieldsOnly=false] Keeps only properties that reference a field
*/
interface MessageConversionOptions {
fieldsOnly: boolean;
fieldsOnly?: boolean;
}

/**
Expand Down

0 comments on commit 7eb3d45

Please sign in to comment.