diff --git a/src/fs.ts b/src/fs.ts index 6dc0c1d..cc07bd2 100644 --- a/src/fs.ts +++ b/src/fs.ts @@ -1,7 +1,7 @@ import { promises as fs } from "fs"; import * as path from "path"; -import type { FileAddition } from "./github/graphql/generated/types.ts"; import type { + CommitFilesFromBuffersArgs, CommitFilesFromDirectoryArgs, CommitFilesResult, } from "./interface.ts"; @@ -12,14 +12,15 @@ export const commitFilesFromDirectory = async ({ fileChanges, ...otherArgs }: CommitFilesFromDirectoryArgs): Promise => { - const additions: FileAddition[] = await Promise.all( - (fileChanges.additions || []).map(async (p) => { - return { - path: p, - contents: await fs.readFile(path.join(cwd, p)), - }; - }), - ); + const additions: CommitFilesFromBuffersArgs["fileChanges"]["additions"] = + await Promise.all( + (fileChanges.additions || []).map(async (p) => { + return { + path: p, + contents: await fs.readFile(path.join(cwd, p)), + }; + }), + ); return commitFilesFromBuffers({ ...otherArgs, diff --git a/src/github/codegen.ts b/src/github/codegen.ts index 62741b4..449ed00 100644 --- a/src/github/codegen.ts +++ b/src/github/codegen.ts @@ -17,6 +17,22 @@ if (process.env.CI || !fs.existsSync(schemaPath)) { fs.writeFileSync(schemaPath, await result.text()); } +const scalars = { + Base64String: "string", + BigInt: "string", + CustomPropertyValue: "string", + Date: "string", + DateTime: "string", + GitObjectID: "string", + GitRefname: "string", + GitSSHRemote: "string", + GitTimestamp: "string", + HTML: "string", + PreciseDateTime: "string", + URI: "string", + X509Certificate: "string", +}; + const config: CodegenConfig = { schema: schemaPath, documents: ["src/github/graphql/queries.ts"], @@ -24,16 +40,16 @@ const config: CodegenConfig = { "src/github/graphql/generated/types.ts": { plugins: ["typescript"], config: { - // TODO: Look into adding stricter types or use `unknown` - defaultScalarType: "any", + scalars, + strictScalars: true, enumsAsTypes: true, }, }, "src/github/graphql/generated/operations.ts": { plugins: ["typescript-operations"], config: { - // TODO: Look into adding stricter types or use `unknown` - defaultScalarType: "any", + scalars, + strictScalars: true, importSchemaTypesFrom: "src/github/graphql/generated/types.ts", importExtension: ".ts", },