JSON Feed Types

I've been working on adding JSON Feed to my blog, but I was surprised to discover that nobody has published JSON Feed TypeScript types yet. So I made some.

The types will give you confidence that your feed complies with the JSON Feed spec and give you documentation from the spec itself in your editor. Pretty cool!

I've only typed version 1.1 of the spec so far. You can get the types from npm:

npm install --save-dev @json-feed-types/1_1

And then use them to type your feed data:

import Feed from '@json-feed-types/1_1'

const feed: Feed = {
version: 'https://jsonfeed.org/version/1.1',
title: 'JSON Feed',
icon: 'https://micro.blog/jsonfeed/avatar.jpg',
home_page_url: 'https://www.jsonfeed.org/',
feed_url: 'https://www.jsonfeed.org/feed.json',
items: [
{
id: 'http://jsonfeed.micro.blog/2020/08/07/json-feed-version.html',
title: 'JSON Feed version 1.1',
content_html:
' We&rsquo;ve updated the spec to version 1.1. It’s a minor update to JSON Feed, clarifying a few things in the spec and adding a couple new fields such as authors and language. \n\n For version 1.1, we&rsquo;re starting to move to the more specific MIME type application/feed+json. Clients that parse HTML to discover feeds should prefer that MIME type, while still falling back to accepting application/json too. \n\n The code page has also been updated with several new code libraries and apps that support JSON Feed. \n',
date_published: '2020-08-07T11:44:36-05:00',
url: 'https://www.jsonfeed.org/2020/08/07/json-feed-version.html',
},
],
}

The types support extensions, too. You can find out more in the readme.