Typescript WTF Moments 7: Boolean can extends Record<infer X,unknown>
Acid Coder
Posted on August 22, 2022
type o = boolean extends Record<infer X, unknown> ? X : false // valueOf
// ^?
console.log(true.valueOf()) // true
Boolean can extends Record because boolean in JS has properties "valueOf"
this may caught you off guard if you expect anything that extends Record is object type
💖 💪 🙅 🚩
Acid Coder
Posted on August 22, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.