UNPKG

@microsoft/api-extractor

Version:

Validatation, documentation, and auditing for the exported API of a TypeScript package

63 lines (61 loc) 2.6 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var ApiItem_1 = require("./ApiItem"); var ApiMember_1 = require("./ApiMember"); var ApiParameter_1 = require("./ApiParameter"); var TypeScriptHelpers_1 = require("../TypeScriptHelpers"); /** * This class is part of the ApiItem abstract syntax tree. It represents functions that are members of * classes, interfaces, or nested type literal expressions. Unlike ApiFunctions, ApiMethods can have * access modifiers (public, private, etc.) or be optional, because they are members of a structured type * * @see ApiFunction for functions that are defined inside of a package */ var ApiMethod = (function (_super) { __extends(ApiMethod, _super); function ApiMethod(options) { var _this = _super.call(this, options) || this; _this.kind = ApiItem_1.ApiItemKind.Method; var methodDeclaration = options.declaration; // Parameters if (methodDeclaration.parameters) { _this.params = []; for (var _i = 0, _a = methodDeclaration.parameters; _i < _a.length; _i++) { var param = _a[_i]; var declarationSymbol = TypeScriptHelpers_1.default.tryGetSymbolForDeclaration(param); var apiParameter = new ApiParameter_1.default({ extractor: _this.extractor, declaration: param, declarationSymbol: declarationSymbol, jsdocNode: param }); _this.innerItems.push(apiParameter); _this.params.push(apiParameter); } } // Return type if (!(_this.name === '__constructor')) { if (methodDeclaration.type) { _this.returnType = methodDeclaration.type.getText(); } else { _this.returnType = 'any'; _this.hasIncompleteTypes = true; } } return _this; } return ApiMethod; }(ApiMember_1.default)); exports.default = ApiMethod; //# sourceMappingURL=ApiMethod.js.map