Skip to content

Commit 8cf9922

Browse files
committed
refactor: improve types
1 parent 7589c71 commit 8cf9922

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/client/client.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { AuthorizationError } from './errors/AuthorizationError'
1212
import { JikePost, JikePostWithDetail } from './post'
1313
import type { CreatePostOption } from '../types/options'
1414
import type { FollowingUpdatesMoreKey, JikeClientJSON } from './types'
15-
import type { FollowingUpdate, Notification, Post } from '../types/entity'
15+
import type {
16+
FollowingUpdate,
17+
Notification,
18+
PersonalUpdate,
19+
Post,
20+
} from '../types/entity'
1621
import type { BeforeRetryState } from 'ky/distribution/types/hooks'
1722
import type { PaginatedFetcher, PaginatedOption } from './utils/paginate'
1823
import type { Api } from '../api'
@@ -237,14 +242,18 @@ export class JikeClient extends EventEmitter<EventMap> {
237242
}),
238243
option
239244
)
240-
return updates.map((update) => {
241-
// TODO repost
242-
if (update.type === 'ORIGINAL_POST') {
243-
return this.getPost(PostType.ORIGINAL, update.id, update)
244-
} else {
245-
return update
245+
return updates.map(
246+
(
247+
update
248+
): ({ actionTime: string } & PersonalUpdate) | JikePostWithDetail => {
249+
// TODO repost
250+
if (update.type === 'ORIGINAL_POST') {
251+
return this.getPost(PostType.ORIGINAL, update.id, update)
252+
} else {
253+
return update
254+
}
246255
}
247-
})
256+
)
248257
}
249258

250259
/**

src/client/post.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ export class JikePost {
169169
}
170170

171171
export class JikePostWithDetail extends JikePost {
172+
detail: Post
173+
172174
constructor(client: JikeClient, type: PostType, id: string, detail: Post) {
173175
super(client, type, id, detail)
174176
this.detail = detail
175177
}
176178

177179
getDetail(): Post {
178-
return this.detail!
180+
return this.detail
179181
}
180182
}

0 commit comments

Comments
 (0)