Dimitri Mitropoulos explains how TypeScript 4.9 prevents errors by catching direct equality checks against NaN.
TypeScript is getting smarter all the time. In 4.9 it's got some new insights about how to handle equality checks for the NaN value. Since nothing is ever equal to NaN (including even NaN itself!), TypeScript can save you from yourself when you try to include NaN in equality or inequality checks.
a fun interview question
a quirk of all number systems
common solutions to this problem
NaN equality checks in JavaScript
IEEE-754 floating point number spec
TypeScript's insights for NaN equality checks
Number.isNaN saves the day
TypeScript is still just JavaScript
audience question: is TypeScript breaking the IEEE 754 spec?
audience comment: semantic meaning of NaN
audience comment: `typeof NaN` is still `number`
audience comment: JS Wat's `baNaNa`
Dimitri Mitropoulos is a functional programming enthusiast that aims to not annoy his colleagues by forcing Ramda into every package. In his free time he likes to write Rust programs, eat soup dumplings, and can often be found in the woodshop making furniture for his friends and family.
Recorded on November 1st at Cahoots (cahoots.com) in Ann Arbor, Michigan.
Discord: discord.gg/tmhGfR4Dye
Twitter: twitter.com/MiTypeScript
Mastodon: fosstodon.org/@MichiganTypeScript
Instagram: instagram.com/michigantypescript
TikTok: tiktok.com/@michigantypescript
Why it's here
1 person recommends this
What people say. Recommended as a helpful breakdown of TypeScript 4.9 features.
d
u/dimitropoulosin r/typescript • Recommends
On “Announcing TypeScript 4.9”
Exciting stuff!
I'm most excited for the property narrowing with the \`in\` operator because it's such a quality-of-life improvement.
On that note, though, Michigan TypeScript developers has videos on some other of the new features in 4.9 as well:
* TypeScript satisfies operator in Storybook
* TypeScript 4.9 Checks for Equality on NaN
* TypeScript's satisfies operator: Intro to 4.9's new feature