Fox Vector's avatar
Fox Vector
stas@layer3.press
npub1drtw...n9vj
The art of programming live book and musings
Fox Vector's avatar
Fox Vector 8 months ago
TypeScript predicates At first glance, a function like isString seems harmless. It tells TypeScript: "If this function returns true, you can trust that the input is a string." But what TypeScript doesn’t do is verify the logic inside that function. You, the developer, are now responsible for proving that assertion is correct. TypeScript simply takes your word for it
Fox Vector's avatar
Fox Vector 8 months ago
TypeScript Lies? The Hidden Risks of Using Predicates! At first glance, a function like isString seems harmless. It tells TypeScript: "If this function returns true, you can trust that the input is a string." But what TypeScript doesn’t do is verify the logic inside that function. You, the developer, are now responsible for proving that assertion is correct. TypeScript simply takes your word for it