Book: Kotlin and Java to TypeScript — A Bridge for JVM Developers
Also by me: The TypeScript Library — the 5-book collection
My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools
Me: xgabriel.com | GitHub
A Java developer joins a TypeScript service. The repository's findUserById returns User | undefined . Their hand reaches for the muscle memory: wrap it. Make it safe. Give the caller a thing that signals absence the way a Java codebase has signalled absence since 2014.
class Optional < T > { private constructor ( private readonly value : T | undefined ) {}
static of < T > ( value : T ): Optional < T > { return new Optional ( value ); } static empty < T > (): Optional < T > { return new Optional < T > ( undefined ); } static ofNullable < T > ( value : T | undefined ): Optional < T > { return new Optional ( value ); }
isPresent (): boolean { return this . value !== undefined ; } get (): T { if ( this .…