Typescript WTF Moments 3: Type of Key is `string` if Key is Template Literal `a/${string}`
Acid Coder
Posted on August 8, 2022
const a = 'a'
const obj = { [a]:1 } // {a:1}
const b = 'b/a' as `b/${string}`
const obj2 = { [b]:1 } // {[x:string]:1}, expecting {[x:`b/${string}`]:1}
this is a known widen string deficiency
it is part of this long going issue
💖 💪 🙅 🚩
Acid Coder
Posted on August 8, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
webdev Enhancing Security in Node.js & TypeScript Applications with JWT Authentication.
February 15, 2024