@ts-ast-parser/core
Version:
Reflects a simplified version of the TypeScript AST for generating documentation
64 lines • 1.66 kB
JavaScript
import { tryAddProperty } from '../utils/try-add-property.js';
import { ExportKind } from '../models/export.js';
import { RootNodeType } from '../models/node.js';
/**
* Represents the reflected node of a re-export declaration.
* For example: `export * from './foo.js'`
*/
export class ReExportNode {
constructor(node, context) {
Object.defineProperty(this, "_node", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_context", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this._node = node;
this._context = context;
}
getName() {
return '*';
}
getOriginalName() {
return this.getName();
}
getKind() {
return ExportKind.Star;
}
getNodeType() {
return RootNodeType.Export;
}
getContext() {
return this._context;
}
getModule() {
return this._node.moduleSpecifier?.getText() ?? '';
}
getTSNode() {
return this._node;
}
isTypeOnly() {
return !!this._node.isTypeOnly;
}
/**
* Serializes the reflected node
*
* @returns The reflected node as a serializable object
*/
serialize() {
const tmpl = {
name: this.getName(),
kind: this.getKind(),
};
tryAddProperty(tmpl, 'module', this.getModule());
tryAddProperty(tmpl, 'typeOnly', this.isTypeOnly());
return tmpl;
}
}
//# sourceMappingURL=re-export-node.js.map