UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

46 lines (45 loc) 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var errors = require("../../../errors"); var typescript_1 = require("../../../typescript"); var utils_1 = require("../../../utils"); var callBaseSet_1 = require("../callBaseSet"); var callBaseGetStructure_1 = require("../callBaseGetStructure"); function AmbientableNode(Base) { return /** @class */ (function (_super) { tslib_1.__extends(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.hasDeclareKeyword = function () { return this.getDeclareKeyword() != null; }; class_1.prototype.getDeclareKeywordOrThrow = function () { return errors.throwIfNullOrUndefined(this.getDeclareKeyword(), "Expected to find a declare keyword."); }; class_1.prototype.getDeclareKeyword = function () { return this.getFirstModifierByKind(typescript_1.SyntaxKind.DeclareKeyword); }; class_1.prototype.isAmbient = function () { return utils_1.isNodeAmbientOrInAmbientContext(this); }; class_1.prototype.setHasDeclareKeyword = function (value) { this.toggleModifier("declare", value); return this; }; class_1.prototype.set = function (structure) { callBaseSet_1.callBaseSet(Base.prototype, this, structure); if (structure.hasDeclareKeyword != null) this.setHasDeclareKeyword(structure.hasDeclareKeyword); return this; }; class_1.prototype.getStructure = function () { return callBaseGetStructure_1.callBaseGetStructure(Base.prototype, this, { hasDeclareKeyword: this.hasDeclareKeyword() }); }; return class_1; }(Base)); } exports.AmbientableNode = AmbientableNode;