@@ -65,7 +65,7 @@ export function FeedService() {
6565 const avatar = extractImage ( content ) ;
6666 return {
6767 summary : summary . length > 0 ? summary : content . length > 100 ? content . slice ( 0 , 100 ) : content ,
68- hashtags : ( hashtags as any ) . map ( ( { hashtag } : any ) => hashtag ) ,
68+ hashtags : ( hashtags as unknown as { hashtag : { id : number ; name : string } } [ ] ) . map ( ( { hashtag } ) => hashtag ) ,
6969 avatar,
7070 ...other
7171 }
@@ -198,7 +198,7 @@ export function FeedService() {
198198 }
199199
200200 const { hashtags, ...other } = feed ;
201- const hashtags_flatten = ( hashtags as any ) . map ( ( f : any ) => f . hashtag ) ;
201+ const hashtags_flatten = ( hashtags as unknown as { hashtag : { id : number ; name : string } } [ ] ) . map ( ( f ) => f . hashtag ) ;
202202
203203
204204 // update visits
@@ -255,11 +255,19 @@ export function FeedService() {
255255
256256 const cache = PublicCache ( ) ;
257257 function formatAndCacheData (
258- feed : any ,
258+ feed : {
259+ id : number ;
260+ title : string | null ;
261+ summary : string ;
262+ content : string ;
263+ createdAt : Date ;
264+ updatedAt : Date ;
265+ hashtags : { hashtag : { id : number ; name : string } } [ ] ;
266+ } | null | undefined ,
259267 feedDirection : "previous_feed" | "next_feed" ,
260268 ) {
261269 if ( feed ) {
262- const hashtags_flatten = ( feed . hashtags as any ) . map ( ( f : any ) => f . hashtag ) ;
270+ const hashtags_flatten = ( feed . hashtags as unknown as { hashtag : { id : number ; name : string } } [ ] ) . map ( ( f ) => f . hashtag ) ;
263271 const summary =
264272 feed . summary . length > 0
265273 ? feed . summary
@@ -508,7 +516,7 @@ export function FeedService() {
508516 } ) ) ) . map ( ( { content, hashtags, summary, ...other } ) => {
509517 return {
510518 summary : summary . length > 0 ? summary : content . length > 100 ? content . slice ( 0 , 100 ) : content ,
511- hashtags : ( hashtags as any ) . map ( ( { hashtag } : any ) => hashtag ) ,
519+ hashtags : ( hashtags as unknown as { hashtag : { id : number ; name : string } } [ ] ) . map ( ( { hashtag } ) => hashtag ) ,
512520 ...other
513521 }
514522 } ) ;
@@ -554,16 +562,16 @@ export function FeedService() {
554562 set . status = 404 ;
555563 return 'No items found' ;
556564 }
557- const feedItems : FeedItem [ ] = items ?. map ( ( item : any ) => {
558- const createdAt = new Date ( item ?. [ 'wp:post_date' ] ) ;
559- const updatedAt = new Date ( item ?. [ 'wp:post_modified' ] ) ;
560- const draft = item ?. [ 'wp:status' ] !== 'publish' ;
561- const contentHtml = item ?. [ 'content:encoded' ] ;
565+ const feedItems : FeedItem [ ] = items ?. map ( ( item : WPItem ) => {
566+ const createdAt = new Date ( item [ 'wp:post_date' ] ) ;
567+ const updatedAt = new Date ( item [ 'wp:post_modified' ] ) ;
568+ const draft = item [ 'wp:status' ] !== 'publish' ;
569+ const contentHtml = item [ 'content:encoded' ] ;
562570 const content = html2md ( contentHtml ) ;
563571 const summary = content . length > 100 ? content . slice ( 0 , 100 ) : content ;
564- let tags = item ?. [ ' category' ] ;
572+ let tags = item . category ;
565573 if ( tags && Array . isArray ( tags ) ) {
566- tags = tags . map ( ( tag : any ) => tag + '' ) ;
574+ tags = tags . map ( ( tag : string ) => tag + '' ) ;
567575 } else if ( tags && typeof tags === 'string' ) {
568576 tags = [ tags ] ;
569577 }
@@ -623,6 +631,15 @@ export function FeedService() {
623631}
624632
625633
634+ interface WPItem {
635+ title : string ;
636+ 'wp:post_date' : string ;
637+ 'wp:post_modified' : string ;
638+ 'wp:status' : string ;
639+ 'content:encoded' : string ;
640+ category ?: string | string [ ] ;
641+ }
642+
626643type FeedItem = {
627644 title : string ;
628645 summary : string ;
0 commit comments