From 43fc3bdb57708636ebb57262e8bcff2f735fb338 Mon Sep 17 00:00:00 2001 From: Amol Bhave Date: Tue, 24 Sep 2024 13:06:45 -0500 Subject: [PATCH] fix(types): add explicit `| undefined` to optional fields (#462) When typescript is used with the option `exactOptionalProperty: true`, this code fails to typecheck if `undefined` is passed in for the response value. This is because `exactOptionalProperty` makes tsc consider `?:..` different from `: ... | undefined` for more strictness. --- src/index.ts | 2 +- src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index facdfc3..9725588 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,7 @@ export class RequestError extends Error { /** * Response object if a response was received */ - response?: OctokitResponse; + response?: OctokitResponse | undefined; constructor( message: string, diff --git a/src/types.ts b/src/types.ts index 4e0e5f6..a971a5a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ import type { RequestOptions, OctokitResponse } from "@octokit/types"; export type RequestErrorOptions = { - response?: OctokitResponse; + response?: OctokitResponse | undefined; request: RequestOptions; };