Skip to content

Commit dfb90a2

Browse files
committed
refactor(api): use @octokit/types REST schema type
Signed-off-by: Adam Setch <[email protected]>
1 parent 81628e5 commit dfb90a2

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/renderer/typesGitHub.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ type GitHubSubject = Omit<
7777
type: SubjectType;
7878
};
7979

80+
type StrengthenNullable<T, K extends keyof T, Extra> = Omit<T, K> & {
81+
[P in K]: T[P] extends null ? null : NonNullable<T[P]> & Extra;
82+
};
83+
8084
// Exported strengthened types
8185
export type Notification = GitHubNotification & GitifyNotification;
8286

@@ -97,20 +101,18 @@ export type Owner = Omit<
97101
avatar_url: Link;
98102
};
99103

100-
export type Commit = Omit<BaseCommit, 'author'> & {
101-
author: BaseCommit['author'] extends null
102-
? null
103-
: NonNullable<BaseCommit['author']> & { type: UserType };
104-
};
105-
106-
export type CommitComment = Omit<BaseCommitComment, 'user'> & {
107-
user: BaseCommitComment['user'] extends null
108-
? null
109-
: NonNullable<BaseCommitComment['user']> & { type: UserType };
110-
};
111-
112-
export type Release = Omit<BaseRelease, 'author'> & {
113-
author: BaseRelease['author'] extends null
114-
? null
115-
: NonNullable<BaseRelease['author']> & { type: UserType };
116-
};
104+
export type Commit = StrengthenNullable<
105+
BaseCommit,
106+
'author',
107+
{ type: UserType }
108+
>;
109+
export type CommitComment = StrengthenNullable<
110+
BaseCommitComment,
111+
'user',
112+
{ type: UserType }
113+
>;
114+
export type Release = StrengthenNullable<
115+
BaseRelease,
116+
'author',
117+
{ type: UserType }
118+
>;

0 commit comments

Comments
 (0)