Skip to content

Commit 88d0566

Browse files
authored
Drop generic Unwrap in favor of built-in Awaited (#18)
Awaited came in TS 4.5, after the first implementation of github-blog, so I needed to create Unwrap
1 parent 0c4a594 commit 88d0566

File tree

6 files changed

+5
-12
lines changed

6 files changed

+5
-12
lines changed

src/methods/getComments.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { gql } from "code-tag";
2-
import type { Unwrap } from "../types";
32
import type { GithubBlog } from "../github-blog";
43
import { GithubQueryParams } from "../utils/github-query";
54
import { PagerParams } from "../utils/pager";
@@ -73,4 +72,4 @@ export const getComments = (blog: GithubBlog) => async (params: GetCommentsParam
7372

7473
export type GetComments = ReturnType<typeof getComments>;
7574

76-
export type GetCommentsResult = Unwrap<ReturnType<GetComments>>;
75+
export type GetCommentsResult = Awaited<ReturnType<GetComments>>;

src/methods/getLabels.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { gql } from "code-tag";
22
import type { GithubBlog } from "../github-blog";
3-
import type { Unwrap } from "../types";
43
import { isNonNull } from "../utils/func";
54
import { PagerParams } from "../utils/pager";
65
import { Label } from "../datatypes/Label";
@@ -70,4 +69,4 @@ export const getLabels = (blog: GithubBlog) => async (params?: GetLabelsParams)
7069

7170
export type GetLabels = ReturnType<typeof getLabels>;
7271

73-
export type GetLabelsResult = Unwrap<ReturnType<GetLabels>>;
72+
export type GetLabelsResult = Awaited<ReturnType<GetLabels>>;

src/methods/getPinnedPosts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { gql } from "code-tag";
2-
import type { Unwrap } from "../types";
32
import type { GithubBlog } from "../github-blog";
43
import { isNonNull } from "../utils/func";
54
import { PostReduced } from "../datatypes/PostReduced";
@@ -40,4 +39,4 @@ export const getPinnedPosts = (blog: GithubBlog) => async () => {
4039

4140
export type GetPinnedPosts = ReturnType<typeof getPinnedPosts>;
4241

43-
export type GetPinnedPostsResult = Unwrap<ReturnType<GetPinnedPosts>>;
42+
export type GetPinnedPostsResult = Awaited<ReturnType<GetPinnedPosts>>;

src/methods/getPost.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { gql } from "code-tag";
2-
import type { Unwrap } from "../types";
32
import type { GithubBlog } from "../github-blog";
43
import { Post } from "../datatypes/Post";
54
import { GithubQueryParams } from "../utils/github-query";
@@ -38,4 +37,4 @@ export const getPost = (blog: GithubBlog) => async (params: GetPostParams) => {
3837

3938
export type GetPost = ReturnType<typeof getPost>;
4039

41-
export type GetPostResult = Unwrap<ReturnType<GetPost>>;
40+
export type GetPostResult = Awaited<ReturnType<GetPost>>;

src/methods/getPosts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { gql } from "code-tag";
2-
import type { Unwrap } from "../types";
32
import type { GithubBlog } from "../github-blog";
43
import { GithubQueryParams } from "../utils/github-query";
54
import { isNonNull } from "../utils/func";
@@ -65,4 +64,4 @@ export const getPosts = (blog: GithubBlog) => async (params: GetPostsParams) =>
6564

6665
export type GetPosts = ReturnType<typeof getPosts>;
6766

68-
export type GetPostsResult = Unwrap<ReturnType<GetPosts>>;
67+
export type GetPostsResult = Awaited<ReturnType<GetPosts>>;

src/types/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
export * from "../__generated__/index";
2-
3-
export type Unwrap<T> = T extends Promise<infer U> ? U : never;

0 commit comments

Comments
 (0)