@ng-doc/builder
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
37 lines • 1.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.displayType = displayType;
exports.formatType = formatType;
exports.displayReturnType = displayReturnType;
const ts_morph_1 = require("ts-morph");
/**
* Display type of the node.
* Structures don't return inferred types, so we need to get the type from the node.
* @param node
* @param typeFormatFlags
*/
function displayType(node, typeFormatFlags = ts_morph_1.TypeFormatFlags.NoTruncation) {
return ts_morph_1.Node.isTypeAliasDeclaration(node)
? node.getTypeNodeOrThrow().getText(undefined)
: formatType(node.getType(), typeFormatFlags);
}
/**
*
* @param type
* @param typeFormatFlags
*/
function formatType(type, typeFormatFlags = ts_morph_1.TypeFormatFlags.NoTruncation) {
return type.getText(undefined, typeFormatFlags);
}
/**
*
* @param node
* @param typeFormatFlags
*/
function displayReturnType(node, typeFormatFlags = ts_morph_1.TypeFormatFlags.NoTruncation) {
if (ts_morph_1.Node.isReturnTyped(node)) {
return node.getReturnType().getText(undefined, typeFormatFlags);
}
return '';
}
//# sourceMappingURL=display-type.js.map
;