Skip to content

Commit

Permalink
Mark generateFiles imports as optional (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed May 6, 2024
1 parent cc0bddc commit 994470f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/generate/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ type QueryType = Awaited<ReturnType<(typeof $)["analyzeQuery"]>>;
export function generateFiles(params: {
target: Target;
path: string;
types: QueryType;
types: Omit<QueryType, "imports" | "importMap"> &
Partial<Pick<QueryType, "imports" | "importMap">>;
}): {
path: string;
contents: string;
Expand Down Expand Up @@ -220,8 +221,10 @@ ${params.types.query.trim().replace(/`/g, "\\`")}\`${hasArgs ? `, args` : ""});
`;

const tsImports =
(params.types as unknown as { importMap?: ImportMap }).importMap ??
new ImportMap([["edgedb", params.types.imports]]);
params.types.importMap ??
new ImportMap(
params.types.imports ? [["edgedb", params.types.imports]] : []
);
tsImports.add("edgedb", "Executor");

const tsImpl = `${queryDefs}
Expand Down

0 comments on commit 994470f

Please sign in to comment.