UNPKG

@microsoft/api-extractor

Version:

Validate, document, and review the exported API for a TypeScript library

46 lines (44 loc) 1.51 kB
"use strict"; // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); const AstItem_1 = require("./AstItem"); const AstMember_1 = require("./AstMember"); /** * This class is part of the AstItem abstract syntax tree. It represents properties of classes or interfaces * (It does not represent member methods) */ class AstProperty extends AstMember_1.default { constructor(options) { super(options); this.kind = AstItem_1.AstItemKind.Property; const declaration = options.declaration; if (declaration.type) { this.type = declaration.type.getText(); } else { this.hasIncompleteTypes = true; this.type = 'any'; } if (this.documentation.hasReadOnlyTag) { this.isReadOnly = true; } else { // Check for a readonly modifier for (const modifier of declaration.modifiers || []) { if (modifier.kind === ts.SyntaxKind.ReadonlyKeyword) { this.isReadOnly = true; } } } } getDeclarationLine() { return super.getDeclarationLine({ type: this.type, readonly: this.isReadOnly }); } } exports.default = AstProperty; //# sourceMappingURL=AstProperty.js.map