@@ -54,13 +54,13 @@ async function readFileAtRevision(
5454 ) ;
5555}
5656
57- interface countFromGitArgs {
57+ interface countFromGitArgs < T extends BufferSource > {
5858 GIT_BIN ?: string ;
5959 cwd: string ;
6060 repoURL: string ;
6161 branch: string ;
6262 subPath: string ;
63- privateKey ? : ArrayBuffer ;
63+ privateKey ? : T ;
6464 keyParts: string [ ] ;
6565 firstCommitRef: string ;
6666 lastCommitRef ? : string ;
@@ -71,7 +71,7 @@ interface countFromGitArgs {
7171 doNotCleanTempFiles: boolean ;
7272}
7373
74- export default async function countFromGit ( {
74+ export default async function countFromGit < T extends BufferSource = BufferSource > ( {
7575 GIT_BIN = "git" ,
7676 cwd,
7777 repoURL,
@@ -86,9 +86,9 @@ export default async function countFromGit({
8686 pushToRemote = true ,
8787 gpgSign,
8888 doNotCleanTempFiles,
89- } : countFromGitArgs ) : Promise < {
89+ } : countFromGitArgs < T > ) : Promise < {
9090 result : VoteResult ;
91- privateKey: ArrayBuffer ;
91+ privateKey : T ;
9292 readonly privateKeyAsArmoredString : string ;
9393 } > {
9494 const spawnArgs = { cwd } ;
@@ -150,7 +150,7 @@ export default async function countFromGit({
150150 keyParts ?. map ( ( part : string | BufferSource ) =>
151151 typeof part === "string" ? Buffer . from ( part , "base64" ) : part ,
152152 ) ,
153- ) ;
153+ ) as T ;
154154 }
155155
156156 if ( mailmap != null ) {
@@ -343,7 +343,7 @@ export default async function countFromGit({
343343 result,
344344 privateKey,
345345 get privateKeyAsArmoredString ( ) {
346- const base64Key = Buffer . from ( privateKey ) . toString ( "base64" ) ;
346+ const base64Key = Buffer . from ( privateKey as ArrayBuffer ) . toString ( "base64" ) ;
347347 let key = "-----BEGIN PRIVATE KEY-----\n" ;
348348 for ( let i = 0 ; i < base64Key . length ; i += 64 ) {
349349 key += base64Key . slice ( i , i + 60 ) + "\n" ;
0 commit comments