Functions, Generics, and the Stuff That Looks Familiar But Isn't
My project: Hermes IDE | GitHub Me: gabrielanhaia Java generics feel like paperwork. TypeScript generics feel like a tool. Same concept, very different experience. I spent years writing Java and PH...

Source: DEV Community
My project: Hermes IDE | GitHub Me: gabrielanhaia Java generics feel like paperwork. TypeScript generics feel like a tool. Same concept, very different experience. I spent years writing Java and PHP before picking up TypeScript. The generics syntax looked familiar enough. <T>, constraints, return types. But once I started writing real code, I realized the similarities were surface-level. Functions in TypeScript behave differently than methods in Java. Generics show up in places I didn't expect. And there's a whole category of type-level features -- type guards, satisfies, structural constraints -- that don't map to anything in my previous stack. This is Post 3 in the series. Post 1 covered the mental model shift. Post 2 covered the type system, unions, and discriminated unions. If you haven't read those, the generics section here will still make sense, but the type narrowing part builds on concepts from Post 2. Functions Are Values, Not Just Methods Every function in Java lives i