ts-simple-ast
Version:
TypeScript compiler wrapper for static analysis and code manipulation.
44 lines (43 loc) • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var errors = require("../../../errors");
var base_1 = require("../base");
var common_1 = require("../common");
exports.BindingElementBase = base_1.InitializerExpressionableNode(base_1.BindingNamedNode(common_1.Node));
var BindingElement = /** @class */ (function (_super) {
tslib_1.__extends(BindingElement, _super);
function BindingElement() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Gets the binding element's dot dot dot token (...) if it exists or throws if not.
*/
BindingElement.prototype.getDotDotDotTokenOrThrow = function () {
return errors.throwIfNullOrUndefined(this.getDotDotDotToken(), "Expected to find a dot dot dot token (...).");
};
/**
* Gets the binding element's dot dot dot token (...) if it exists or returns undefined.
*/
BindingElement.prototype.getDotDotDotToken = function () {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.dotDotDotToken);
};
/**
* Gets binding element's property name node or throws if not found.
*
* For example in `const { a: b } = { a: 5 }`, `a` would be the property name.
*/
BindingElement.prototype.getPropertyNameNodeOrThrow = function () {
return errors.throwIfNullOrUndefined(this.getPropertyNameNode(), "Expected to find a property name node.");
};
/**
* Gets binding element's property name node or returns undefined if not found.
*
* For example in `const { a: b } = { a: 5 }`, `a` would be the property name.
*/
BindingElement.prototype.getPropertyNameNode = function () {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.propertyName);
};
return BindingElement;
}(exports.BindingElementBase));
exports.BindingElement = BindingElement;