docs icon indicating copy to clipboard operation
docs copied to clipboard

RSS > Using glob imports: pagesGlobToRssItems return is not assignable to rss items

Open JoshuaKGoldberg opened this issue 1 year ago • 0 comments

📚 Subject area/topic

RSS

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/guides/rss/#using-glob-imports

📋 Description of content that is out-of-date or incorrect

I'm trying to do exactly what he src/pages/rss.xml.js example proposes for items: await pageGlobToRssItems(...). But I'm getting a TypeScript error on the items. Its tl;dr is that some properties are option in the returned items schema from pagesGlobToRssItems, but required in the schema for the items parameter property in rss:

  • link
  • pubDate
  • title
Type '{ title?: string | undefined; description?: string | undefined; pubDate?: Date | undefined; customData?: string | undefined; categories?: string[] | undefined; author?: string | undefined; ... 4 more ...; content?: string | undefined; }[]' is not assignable to type 'Record<string, (...args: unknown[]) => Promise<any>> | RSSFeedItem[]'.
  Type '{ title?: string | undefined; description?: string | undefined; pubDate?: Date | undefined; customData?: string | undefined; categories?: string[] | undefined; author?: string | undefined; ... 4 more ...; content?: string | undefined; }[]' is not assignable to type 'RSSFeedItem[]'.
    Type '{ title?: string | undefined; description?: string | undefined; pubDate?: Date | undefined; customData?: string | undefined; categories?: string[] | undefined; author?: string | undefined; ... 4 more ...; content?: string | undefined; }' is not assignable to type 'RSSFeedItem'.
      Property 'link' is optional in type '{ title?: string | undefined; description?: string | undefined; pubDate?: Date | undefined; customData?: string | undefined; categories?: string[] | undefined; author?: string | undefined; ... 4 more ...; content?: string | undefined; }' but required in type 'RSSFeedItem'.ts(2322)

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

https://stackblitz.com/edit/github-wcs5ut?file=package.json,src%2Fpages%2Frss.xml.ts

JoshuaKGoldberg avatar Jan 23 '24 21:01 JoshuaKGoldberg