UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

28 lines (27 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var typescript_1 = require("../../../typescript"); var errors = require("../../../errors"); var utils_1 = require("../../../utils"); function NamespaceChildableNode(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.getParentNamespaceOrThrow = function () { return errors.throwIfNullOrUndefined(this.getParentNamespace(), "Expected to find the parent namespace."); }; class_1.prototype.getParentNamespace = function () { var parent = this.getParentOrThrow(); if (!utils_1.TypeGuards.isModuleBlock(parent)) return undefined; while (parent.getParentOrThrow().getKind() === typescript_1.SyntaxKind.ModuleDeclaration) parent = parent.getParentOrThrow(); return parent; }; return class_1; }(Base)); } exports.NamespaceChildableNode = NamespaceChildableNode;