Skip to content

Commit

Permalink
CLI: Prefer @tstype over @type when generating typedefs (tsd-jsdoc)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Apr 12, 2017
1 parent 6c37dbd commit b355115
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions cli/lib/tsd-jsdoc/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,20 @@ function handleTypeDef(element, parent) {
if (element.templates && element.templates.length)
write("<", element.templates.join(", "), ">");
write(" = ");
var type = getTypeOf(element);
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")
writeFunctionSignature(element, false, true);
else if (type === "object") {
if (element.properties && element.properties.length)
writeInterfaceBody(element);
else
write("{}");
} else
write(type);
if (element.tsType)
write(element.tsType);
else {
var type = getTypeOf(element);
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")
writeFunctionSignature(element, false, true);
else if (type === "object") {
if (element.properties && element.properties.length)
writeInterfaceBody(element);
else
write("{}");
} else
write(type);
}
writeln(";");
}
}
2 changes: 2 additions & 0 deletions src/typescript.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
* Constructor type.
* @typedef Constructor
* @template T extends object
* @type {Function}
* @tstype { new(...params: any[]): T }
*/

/**
* Properties type.
* @typedef Properties
* @template T extends object
* @type {Object.<string,*>}
* @tstype { [P in keyof T]?: T[P] } & { [key: string]: any }
*/

0 comments on commit b355115

Please sign in to comment.