ESP32 microcontroller

A very good introduction to the ESP32 microcontroller.

These IoT devices are ten times faster than an Arduino and with a 32 bit architecture they come with a lot more computational capability. In addition they come with a decent amount of memory and built in Wifi, Bluetooth. There’s even an onboard Hall effect detector (detects magnetic fields).

The best part is that you can get boards for around $10.

Prefer interfaces

In Typescript you can declare data structures in one of two ways

1. As type aliases
2. As interfaces

Most devs use these interchangeable but there are good reasons to prefer interfaces over type aliases: size and performance

The problem is particularly noticeable on larger codebases. Type aliases are always expanded inline while interfaces are always referenced by name.

If you want to keep your code smaller and loading faster, prefer interfaces

https://ncjamieson.com/prefer-interfaces/

Typing arrow functions in TSX

JSX in Typescript (i.e. TSX) has an ambiguous grammar which can cause problems in you code.

If you are using an arrow function and want to use a type variable in it, it’s going to mistake the generic syntax eg. <T> for HTML and will not compile.

const foo = <T>(x: T) => x;

If you look for a solution to this on the internet you’re likely to come across this weird syntax which in my opinion completely obscures what you are trying to achieve.

const foo = <T extends {}>(x: T) => x;

Far neater and to the point is this

const foo = <T,>(x: T) => x;

The comma lets the parser know that it’s looking at a type variable and not HTML.