Skip to content

Commit

Permalink
Generate a Mounts type in component codegen (#29609)
Browse files Browse the repository at this point in the history
Generate a Mounts type in component codegen

GitOrigin-RevId: 1009bd46515be96a8dfedc09e02c49c779923e3f
  • Loading branch information
thomasballinger authored and Convex, Inc. committed Sep 7, 2024
1 parent 2b19ba1 commit 7003484
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/cli/codegen_templates/component_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ async function* codegenApiWithMounts(
definitionPath: ComponentDefinitionPath,
): AsyncGenerator<string> {
const mountTree = await buildMountTree(ctx, startPush, definitionPath, []);
if (!mountTree) {
if (mountTree) {
yield "export type Mounts = ";
yield* codegenMountTree(mountTree);
yield `;`;
yield `// For now fullApiWithMounts is only fullApi which provides`;
yield `// jump-to-definition in component client code.`;
yield `// Use Mounts for the same type without the inference.`;
yield "declare const fullApiWithMounts: typeof fullApi;";
} else {
yield "declare const fullApiWithMounts: typeof fullApi;";
return;
}
yield "declare const fullApiWithMounts: typeof fullApi &";
yield* codegenMountTree(mountTree);
yield `;`;
}

function* codegenMountTree(tree: MountTree): Generator<string> {
Expand Down

0 comments on commit 7003484

Please sign in to comment.