Starting my journey with TypeScript after a background in JavaScript.
In the realm of modern JavaScript, one can easily destructure objects like this:
let {n,s} = {n:42, s:'test'};
console.log(n, s); // 42 test
Assuming TypeScript follows suit, I tried to apply the same concept. According to the documentation, both declarations and assignments support destructuring. However, my attempt to mimic the JavaScript syntax failed as shown in this sample code:
let {n:number, s:string} = {n:42, s:'test'}; // All destructured elements are unused.
console.log(n, s); // Cannot find name 'n' (nor 's')
What am I overlooking here?