diff --git a/packages/contented-processor/src/ContentedCodegen.ts b/packages/contented-processor/src/ContentedCodegen.ts index e0ad9430..c0febc76 100644 --- a/packages/contented-processor/src/ContentedCodegen.ts +++ b/packages/contented-processor/src/ContentedCodegen.ts @@ -12,9 +12,9 @@ export class ContentedCodegen { async generateIndex() { const types = this.config.pipelines.map((pipeline) => pipeline.type); const ast = generateIndexAST([...new Set(types)]); - const outPath = join(this.outPath, `index.js`); await fs.mkdir(this.outPath, { recursive: true }); - await fs.writeFile(outPath, generate(ast).code); + await fs.writeFile(join(this.outPath, `index.js`), generate(ast).code); + await fs.writeFile(join(this.outPath, `index.d.ts`), generateTypes(types)); } async generatePipeline(type: string, contents: FileIndex[]) { @@ -204,3 +204,7 @@ function generate(ast: any) { const gen = new CodeGenerator(ast); return gen.generate(); } + +function generateTypes(types: string[]): string { + return types.map((type) => `export declare const ${type}Index: FileIndex[];`).join('\n'); +}