UNPKG

mdxlayer

Version:

Transform your MDX content into typed, JSON-powered data with flexible schema validation.

20 lines (16 loc) 545 B
import { cache } from '../../cache/index.js'; import { transformFile } from '../../utils/transform.js'; const toIndexDts = (exp, docType) => { const content = `import type { ${docType} } from './types'; export * from './types'; ${Object.keys(exp).map((impName) => `export declare const ${impName}: ${docType}[];`).join("\n")}`; const isChanged = cache.changed(content, "index.d.ts"); if (isChanged) { transformFile({ doc: content, filename: "index.d.ts", subpath: "generated" }); } }; export { toIndexDts };