Blog

TypeScript Quirks: This or that, or not - type guards

Figuring out the types of things in typescript is pretty straight forward. We can tell if something is a number, or string, or undefined. We can check the instanceof classes… but for a beginner it may not be immediately obvious how we tell the different between two plain objects.

Read more

TypeScript Quirks: Conditionally required stuff

Say you have a component that should only render some content, provided as a prop, if another prop is true. interface IProps { renderContent?: boolean; content?: string; } const Component = ({renderContent, content}: IProps) => ( <div> {renderContent && content} </div> ); In this case we could tell the component...

Read more

TypeScript Quirks: Getting grandma's number - NaN

Everybody loves their Nan (or at least most of us)… but I doubt very many of us love NaN, and with good reason. Below we have a function that takes a number, and adds one to it.

Read more

TypeScript Quirks: Undefined vs undefined

Like javascript, typescript has more than one type of undefined / defined… Oh, you didn’t know that? Yeah, it’s kind of crazy. So in javascript we can have the 2 following kinds of undefined (and possibly a 3rd if you’re creating an array with Array(10)?).

Read more

Hello, World!
  • Posted: 01 Jan 2000
  • Tags:

So, as you may have guessed, this post was not actually published in the year 2000, but I had to change the date in order to make the blog read with a sensible chronology. You see, I’ve been writing stuff to put on a blog for years, and most of...

Read more

Page 2 of 2