From 58d17f9141938e2de474c6825a6fe311621e3101 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:40:45 -0400 Subject: [PATCH] refactor: adapt code for the `exactOptionalPropertyTypes` (#577) * refactor: adapt code for the `exactOptionalPropertyTypes` * test: enable `exactOptionalPropertyTypes` in `test:typescript` --- package.json | 2 +- src/index.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2b1cc573e..29aece68e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "lint:fix": "prettier --write {src,test}/* *.md package.json", "pretest": "npm run -s lint", "test": "vitest run --coverage", - "test:typescript": "npx tsc --allowImportingTsExtensions --noEmit --declaration --noUnusedLocals --esModuleInterop --strict --target es2022 --moduleResolution node16 --module node16 test/typescript-validate.ts" + "test:typescript": "npx tsc --allowImportingTsExtensions --noEmit --declaration --noUnusedLocals --esModuleInterop --strict --target es2022 --moduleResolution node16 --module node16 --exactOptionalPropertyTypes test/typescript-validate.ts" }, "repository": "github:octokit/app.js", "author": "Gregor Martynus (https://github.com/gr2m)", diff --git a/src/index.ts b/src/index.ts index b516def1d..cebd79ef2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { Octokit as OctokitCore } from "@octokit/core"; +import { Octokit as OctokitCore, type OctokitOptions } from "@octokit/core"; import { createAppAuth } from "@octokit/auth-app"; import { OAuthApp } from "@octokit/oauth-app"; import type { Webhooks } from "@octokit/webhooks"; @@ -99,11 +99,16 @@ export class App { : {}, ); - this.octokit = new Octokit({ + const octokitOptions: OctokitOptions = { authStrategy: createAppAuth, auth: authOptions, - log: options.log, - }) as OctokitType; + }; + + if ("log" in options && typeof options.log !== "undefined") { + octokitOptions.log = options.log; + } + + this.octokit = new Octokit(octokitOptions) as OctokitType; this.log = Object.assign( {