If TypeScript is a strict superset of JavaScript, why is dot notation on an arbitrary object erroneous? I have JS code that I want to convert over to TS for better type safe
x does not hold any property named bar so you need create it within the object:
x
bar
function foobar() { var x = { foo: 'foo', bar: 'bar' } return x; } alert(foobar().bar); //returns bar