Skip to content

Commit

Permalink
fix(types): add explicit | undefined to optional fields (#462)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ammubhave authored Sep 24, 2024
1 parent cd5dc6e commit 43fc3bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class RequestError extends Error {
/**
* Response object if a response was received
*/
response?: OctokitResponse<unknown>;
response?: OctokitResponse<unknown> | undefined;

constructor(
message: string,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RequestOptions, OctokitResponse } from "@octokit/types";

export type RequestErrorOptions = {
response?: OctokitResponse<unknown>;
response?: OctokitResponse<unknown> | undefined;
request: RequestOptions;
};

0 comments on commit 43fc3bd

Please sign in to comment.