Permalink
Browse files

CLI: Prefer @tstype over @type when generating typedefs (tsd-jsdoc)

  • Loading branch information...
dcodeIO committed Apr 12, 2017
1 parent 6c37dbd commit b355115e619c6595ac9d91897cfe628ef0e46054
Showing with 16 additions and 10 deletions.
  1. +14 −10 cli/lib/tsd-jsdoc/publish.js
  2. +2 −0 src/typescript.jsdoc
@@ -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,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.