let foo = 123;
let foo = 123;
foo = 123;
foo = 123;
Error : Cannot find name 'foo'
With syntax extensions
function iPityTheFoo(foo) {
console.log(foo.bar + 123);
}
iPityTheFoo({foo:123});
function iPityTheFoo(foo: { bar: number }) {
console.log(foo.bar + 123);
}
// Error property `bar` missing
iPityTheFoo({ foo: 123 });
function iPityTheFoo(foo: { bar: number }) {
console.log(foo.bar + 123);
}
// Error property `bar` not number
iPityTheFoo({ bar: '123' });
function iPityTheFoo(foo: { bar: number }) {
console.log(foo.bar + 123);
}
// Okay
iPityTheFoo({ bar: 123 });