Andrew Hansen
  • Home
  • About
Sign in Subscribe

typescript

A collection of 3 posts
How Children Types Work In React 18 And TypeScript 4
react

How Children Types Work In React 18 And TypeScript 4

One of the coolest features of React is that everything is "just JavaScript" (or TypeScript!) so the library mostly doesn't care what you provide as children as long as it can be rendered to the UI. We even can have functions as children (aka, render props)! But I said you
Jul 28, 2022 6 min read
What is the ! (exclamation mark / bang) operator in TypeScript?
typescript

What is the ! (exclamation mark / bang) operator in TypeScript?

Sometimes in a TypeScript codebase you might see code like this: const bar = myObject!.foo!.bar // or const obj = myObject! The exclamation/bang operator that comes after accessing a property (also called a "postfix bang") is known as a non-null assertion. The use case for this operator is to convert
Apr 15, 2022 5 min read
How to convert a string to 
a number in TypeScript
typescript

How to convert a string to a number in TypeScript

You're writing a TypeScript application and you hit an error like this: Argument of type 'string' is not assignable to parameter of type 'number'.(2345) This could happen for a number of reasons. For example, I often run into this when reading a value from an input field. I intend
Jan 17, 2022 3 min read
Page 1 of 1
Andrew Hansen © 2023
Powered by Ghost