3 ms·
It's not, not without an assertion: https://i.imgur.com/DJjzPDF.png https://i.imgur.com/DJjzPDF.png Well, it's allowed in that it will still compile the code
by Zarel 8y ago
It's not, not without an assertion:
https://i.imgur.com/DJjzPDF.png https://i.imgur.com/DJjzPDF.png
Well, it's allowed in that it will still compile the code (because TypeScript is a superset of JavaScript), but it'll still yell at you.
- recursive 8y agoYes, without an assertion. Just change your compiler options. https://www.typescriptlang.org/play/#src=%20%20let%20foo%20%3D%20%7B%0D%0A%20%20%20%20bar0%3A%2012%2C%0D%0A%20%20%20%20bar1%3A%2014%2C%0D%0A%20%20%20%20bar2%3A%2016%0D%0A%20%20%7D%0D%0A%0D%0A%20%20%2F%2F%20example%201%0D%0A%20%20console.log(foo.bar0)%3B%0D%0A%20%20console.log(foo.bar1)%3B%0D%0A%20%20console.log(foo.bar2)%3B%0D%0A%0D%0A%20%20%2F%2F%20example%202%0D%0A%20%20for(let%20i%20%3D%200%3B%20i%20%3C%203%3B%20i%2B%2B)%20%7B%0D%0A%20%20%20%20console.log(foo%5B'bar'%20%2B%20i%5D)%0D%0A%20%20%7D%0D%0A%20%20 https://www.typescriptlang.org/play/#src=%20%20let%20foo%20%...