Let's start with some types

After more than two decades working with JavaScript I'd become very comfortable with its lack of typing, so I was surprised at how quickly I became a TypeScript adherent.

I find it's almost impossible to start coding without designing types and interfaces for data first.

I started a file under /types/ that will export a bunch of interfaces that describe the most common data types.

export interface Link {
    text: string;
    title: string;
    url: string;

export interface Author {
    name: string;
    contact?: string;
    urls?: Link[];

export type ArchiveFormat = 'YearMonthDay' | 'YearMonth';

export interface Blog {
    title: string;
    url: string;
    description?: string;
    language?: string;
    authors?: Author[];
    archiveFormat: ArchiveFormat;
    archiveWithSlug: boolean;
    indexPosts?: number;

export interface Tag {
    name: string;
    text: string;

export type PostStatus = 'draft' | 'publish';

export interface Post {
    date: Date;
    title: string;
    author: Author;
    guid?: string;
    content?: string;
    excerpt?: string;
    slug?: string;
    tags?: Tag[];
    thumbnail_image?: string;
    opengraph_image?: string;
    previous_link?: Link;
    next_link?: Link;
    status: PostStatus;

Posted in: blogging, code, typescript, javascript, node

Previously: Hello, world!

Next: Baby step: okay let's write some config stuff