Quantcast
Channel: fettblog.eu | TypeScript, JavaScript, Jamstack
Browsing latest articles
Browse All 203 View Live

Why I use TypeScript

You might well see that my blog starts to center around TypeScript a lot recently. This might look like a strong deviation from what I usually blog and advocate: Performant, accessible and resilient...

View Article


Symbols in JavaScript and TypeScript

symbol is a primitive data type in JavaScript and TypeScript, which, amongst other things, can be used for object properties. Compared to number and string, symbols have some unique features that make...

View Article


void in JavaScript and TypeScript

If you come from traditional, strongly typed languages you might be familiar with the concept of void: A type telling you that functions and methods return nothing when called.

View Article

Boolean in JavaScript and TypeScript

boolean is a fun primitive data type in JavaScript. In TypeScript, it allows for a total of four values Wait, four?

View Article

TypeScript: Check for object properties and narrow down type

TypeScript’s control flow analysis lets you narrow down from a broader type to a more narrow type:

View Article


TypeScript: Assertion signatures and Object.defineProperty

In JavaScript, you can define object properties on the fly with Object.defineProperty. This is useful if you want your properties to be read-only or similar. Think of a storage object that has a...

View Article

TypeScript + React: Typing custom hooks with tuple types

I recently stumbled upon a question on Reddit’s LearnTypeScript subreddit regarding custom React hooks. A user wanted to create a toggle custom hook, and stick to the naming convention as regular React...

View Article

Remake, Remodel. Part 4.

I originally wanted to launch my new website on June 1st, but there were more important things happening at the moment than relaunching a tech blog. Truth be told, it was really hard for me focussing...

View Article


TypeScript: Improving Object.keys

TypeScript’s predefined types in lib.d.ts are usually very well-typed and give tons of information on how to use built-in functionality as well as providing you with extra-type safety. Until they...

View Article


TypeScript: Variadic Tuple Types Preview

TypeScript 4.0 is supposed to be released in August 2020, and one of the biggest changes in this release will be variadic tuple types. And even though his feature is hot of the press at the time of...

View Article

Are large node module dependencies an issue?

The other day, I had some friends frowning over the 800KB size of a node application. This brought to my attention that I never really worried about the size of my dependencies in a Node.js application.

View Article

11ty: Generate Twitter cards automatically

For the redesign of this blog, I created Twitter title cards that are generated automatically. So whenever people share my stuff on social media, they get a nice card telling them the article’s title...

View Article

TypeScript: Union to intersection type

Recently, I had to convert a union type into an intersection type. Working on a helper type UnionToIntersection<T> has taught me a ton of things on conditional types and strict function types,...

View Article


Vite with Preact and TypeScript

Update: Please note that this article already has some age and Vite has seen significant updates. Also, the Preact team has created their own preset for Vite which you can find here. Be sure to check...

View Article

TypeScript: Augmenting global and lib.dom.d.ts

Recently I wanted to use a ResizeObserver in my application. ResizeObserver recently landed in all major browsers, but when you use it in TypeScript — at the time of this writing — ResizeObserver won’t...

View Article


TypeScript + React: Component patterns

This list is a collection of component patterns for React when working with TypeScript. See them as an extension to the TypeScript + React Guide that deals with overall concepts and types. This list...

View Article

TypeScript + React: Why I don't use React.FC

In my recent article on TypeScript and React component patterns I’ve stated that I don’t use the built-in type React.FC<> but rather be explicit with typing children. I didn’t state why, and it...

View Article


TypeScript and ECMAScript Modules

Working with real, native, ECMAScript modules is becoming a thing. Tools like Vite, ES Dev server, and Snowpack get their fast development experience from leaving module resolution to the browser....

View Article

this in JavaScript and TypeScript

Sometimes when writing JavaScript, I want to shout “This is ridiculous!”. But then I never know what this refers to.

View Article

Go Preact! ❤️

You might have heard of Preact, the tiny 3KB alternative to React. It has been around for a while, and since its inception, it claims to be API and feature compatible compared to the more widely used...

View Article

My new book: TypeScript in 50 Lessons

I’ve written a new book! On October 6, the pre-release of TypeScript in 50 Lessons started. It’s 450 pages, published by the wonderful people at Smashing Magazine, and available to read right now! The...

View Article


Tidy TypeScript: Prefer union types over enums

This is the first article in a series of articles where I want to highlight ways on how to keep your TypeScript code neat and tidy. This series is heavily opinionated, so don’t be angry if I ditch a...

View Article


Tidy TypeScript: Prefer type aliases over interfaces

This is the second article in a series of articles where I want to highlight ways on how to keep your TypeScript code neat and tidy. By nature, this series is heavily opinionated and is to be taken...

View Article

Tidy TypeScript: Avoid traditional OOP patterns

This is the third article in a series of articles where I want to highlight ways on how to keep your TypeScript code neat and tidy. This series is heavily opinionated and you might find out things you...

View Article

Tidy TypeScript: Name your generics

My book TypeScript in 50 Lessons features interludes. Short texts on TypeScript culture that provide room to breathe between heavy, technical tutorials. One of those interludes gives some opinionated...

View Article


TypeScript: Low maintenance types

I write a lot about TypeScript and I enjoy the benefits it gives me in my daily work a lot. But I have a confession to make, I don’t really like writing types or type annotations. I’m really happy that...

View Article

TypeScript: Narrow types in catch clauses

When you are coming from languages like Java, C++, or C#, you are used to doing your error handling by throwing exceptions. And subsequently, catching them in a cascade of catch clauses. There are...

View Article

Learning Rust and Go

My blog is a chronicle of learning new things. Most of the articles I write are notes on how I solved problems that I found in my everyday work. And every now and then I have to urge to learn something...

View Article

shared, util, core: Schroedinger's module names

I do a lot of architecture work lately, and one thing that seems to appear more often than I thought it would be are module names that have generic-sounding names like shared, util, or core. There is...

View Article



TypeScript + React: Typing Generic forwardRefs

If you are creating component libraries and design systems in React, you might already have fowarded Refs to the DOM elements inside your components.

View Article

TypeScript: Array.includes on narrow types

The Array.prototype.includes function allows searching for a value within an array. If this value is present, the function returns true! How handy! Of course, TypeScript has proper typings for this...

View Article

Upgrading Node.js dependencies after a yarn audit

It’s Tuesday! The day of your weekly dependabot alerts from GitHub! A nice reminder to check on your projects, and usually just a few clicks worth of work, the automatic update is wonderful.

View Article

TypeScript: Unexpected intersections

Sometimes when writing TypeScript, some of the things you’d usually do in JavaScript work a little different and cause some weird, and puzzling situations. Sometimes you just want to assign a value to...

View Article


Error handling in Rust

I started doing university lectures on Rust, as well as holding workshops and trainings. One of the parts that evolved from a couple of slides into a full-blown session was everything around error...

View Article

Dissecting Deno

I had the chance to toy around with Deno recently. And with “toy around” I mean dissecting it into little pieces and see how the sausage was made. So, my view is not from a user’s perspective who wants...

View Article

Rust: Enums to wrap multiple errors

This is a follow-up to Error handling in Rust from a couple of days ago. The moment we want to use error propagation for different error types, we have to rely on trait objects with Box<dyn...

View Article


TypeScript: In defense of any

A couple of days ago I found this beauty on the internet: Give up and use any. That’s a fantastic website, absolutely hilarious! It also shows how much TypeScript has grown in popularity. You have to...

View Article


TypeScript + React: Children types are broken

I currently work with a couple of newcomers to React and teach them both TypeScript and React to create apps. It’s fun, and for me who’s been using that for a while now, it’s a great way of seeing this...

View Article

TypeScript: The humble function overload

With the most recent type system features like conditional types or variadic tuple types, one technique to describe a function’s interface has faded into the background: Function overloads. And there’s...

View Article

Introducing Slides and Coverage

There’s a new section on this website! Since today, you’re able to see full coverage of my workshops and talks in the new slides and coverage section. That’s the announcement. If you want to see more,...

View Article

Getting started with Rust

Learning and teaching Rust has been a big part of me in the last couple of years. Interest in the Rust programming language has brought me to found the Rust Linz meetup with Rainer Stropek, to teach...

View Article


How not to learn TypeScript

“TypeScript and I are never going to be friends”. Oh wow, how often have I heard this phrase? Learning TypeScript, even in 2022, can be frustrating it seems. And for so many different reasons. People...

View Article

The TypeScript converging point

Usually, when doing TypeScript talks, I just open up a code editor and hack away some cool types that help in a certain scenario. This time, I was asked to do the same thing but within a 20-minute time...

View Article


Rust: Tiny little traits

Rust’s trait system has a feature that is often talked about, but which I don’t see used that often in application code: Implementing your traits for types that are not yours. You can see this a lot in...

View Article

10 years of fettblog.eu

I missed a little anniversary. Roughly 10 years ago (on April 8, 2012), I started blogging on fettblog.eu! Time flies! I think this is my longest-running project, let’s take some time to reflect.

View Article


The road to universal JavaScript

Universal JavaScript. JavaScript that works in every environment. JavaScript that runs on both the client and the server, something thinking about for years (see 1, 2). Where are we now?

View Article

TypeScript: Iterating over objects

There is rarely a head-scratcher in TypeScript as prominent as trying to access an object property via iterating through its keys. This is a pattern that’s so common in JavaScript, yet TypeScript seems...

View Article

Announcing the TypeScript Cookbook

Oops, I did it again! I’m writing another book, and it’s again about TypeScript. I’m happy to announce The TypeScript Cookbook, to be published in 2023 by O’Reilly. You can check it out in Early...

View Article

Refactoring in Rust: Abstraction with the Newtype Pattern

The following piece of code takes a PathBuf and extracts the file name, eventually converting it to an ownedString.

View Article


Refactoring in Rust: Introducing Traits

In the same codebase as last time, we extract data from a HashMap<String, String> called headers, presumably dealing with something similar to HTTP headers.

View Article

Browsing latest articles
Browse All 203 View Live