Adventures in TypeScript Typing

This week I had the need to create a rather simple object that I wanted to be properly typed. This object consists of a couple of enums that will be categories with sub-categories that contain an object. This is a simple enough structure really:

const categories = {
category1: {
sub-category: {…}
},
category2: {
sub-category: {…}
}
}

So, let’s type this out shall we? First we need to define the object that will be the value of the sub-categories.

Continue Reading

Thoughts on TypeScript

Over the past few months I’ve started working pretty extensively with TypeScript. For those of you who don’t know what TypeScript is:

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

It provides strong types to JavaScript. It allows for the creation of classes and enforces those classes in your code. If you define a Redpill.Widget class, you can then use that class in your code and the editor enforces the rules you define within that class.

Continue Reading