import { exportStatementChain, exportStatement, importStatement } from "../../ts-ast-utils/index"; import { ExportChainLeaf } from "./ExportChainLeaf"; import { exportChainLeafStatement } from "../types"; /** * @description * An export chain node has all the information, but also all the methods needed to get all its * next export chain nodes. */ export declare class ExportChainNode { /** * @description * The export statement that corresponds to the context export chain node. */ statement: exportStatementChain | importStatement; /** * @description * Absolute path to the ts file that contains the context export statement. */ pathToTsFile: string; /** * @description * The name that will be exposed to the documentation for the resolved export of the context chain node. * * It is `undefined` only if the chain has encountered so far delegation or namespace exports. * * During resolution it might have to be moved to `namespace` if it is eventually realized that it is * a namespace. */ exposedName: string | undefined; /** * @description * The namespace that will be exposed to the documentation for the resolved non chain export. * The array is needed because multiple namespaces may be encountered during the export chain * resolution. */ namespace: string[]; /** * @description * ```ts * export * from "./some/where"; // undefined * export {a as A} from "./some/where"; // "A" * export * as a from "./some/where"; // "a" * export default foo; // "foo" , if it corresponds to an import statement the value should not change, because it will enable finding the resolution index of the import statement for the node module case * ``` * Every `exportedName` from named export or default export chain is a candidate namespace name. * Delegation exports just pass the `exposedName` to the new node. // I am not so sure about this sentence * Namespace exports undefine it and move it to `namespace` array. */ exportedName: string | undefined; /** * @description * ```ts * export * from "./some/where"; // undefined (I am not so sure about it) * export {a as A} from "./some/where"; // "a" * export * as a from "./some/where"; // "a" * export default foo; // "foo" and then for the case of import statement it becomes propertyName ?? name of the import statement * ``` */ importedName: string | undefined; /** * @description * * d = delegation export * n = namespace export * ^ = start of the export chain * . = export chain statement * * A predicate on whether the next named export should create export branches for each variable it exports. * * Only d and n can have `true` should decompose, and that only in the following cases : * ```text * ^ d+ * ^ .* nd* * ``` */ shouldDecompose: boolean; constructor(_: { statement: exportStatementChain | importStatement; pathToTsFile: string; exposedName: string | undefined; namespace: string[]; exportedName: string | undefined; importedName: string | undefined; shouldDecompose: boolean; }); /** * @todo * the returned type can be `ExportChainLeaf[]` xor `ExportChainNode[]` depending on the * provided `statement`, but I do not know how to type it properly. * @todo * Why I do not separate that into its own function? */ static createInitialNode( /** * @description * Export statement for which the chain node is created. */ statement: exportStatement, /** * @description * Absolute path to the ts file that contains the statement. */ pathToTsFile: string): (ExportChainLeaf | ExportChainNode)[]; /** * @description * Converts the next statements that got from `getNextStatements` to export chain nodes or * leafs and returns them. */ getNextNodes(): (ExportChainNode | ExportChainLeaf)[]; /** * @description * It is not the responsibility of this function to give a resolution index or decompose * @todo * I have to take into consideration the case of import statement having type */ getNextStatements(): getNextStatementsReturnTypeElement[]; /** * @description * That is for the case the context export statement is of multiple exports like this : * ```ts * export {A,b as B,default as C,default} from "./some/where";// ["A","B","C","default"] -> [0,1,2,3] * export const a : number = 45, b : string = "32";// ["a","b"] -> [1,2] * ``` * The resolution index defines which one it corresponds to. * It throws for the case the context statement is not named export or variable statement. */ get resolutionIndex(): number; resolve(): ExportChainLeaf[]; } export declare type getNextStatementsReturnTypeElement = { /** * @description * Are import statements only due to export pathless and default export chains? */ newStatement: exportChainLeafStatement; /** * @description * This is for the case of a named export exporting something from a chain of delegation exports. */ newPath: string; };