A Lazy Sequence

Structured messaging followup

In my previous article I defined message types using TypeScript’s type alias facility. It turns out that interface extension is better here as it allows you to define recursive types where aliases do not. Simple change:

export type FooBar = IMessage<FooBarKeyT, {v: number}>;


export interface FooBar extends IMessage<FooBarKeyT, {v: number}> { }

The unioned types – such as `FooMessage` stay the same.

The Interfaces vs. Type Aliases section of the Advanced Types chapter in the TypeScript Handbook covers this briefly.

24 May 2016