Why doesn't TypeScript catch that a const is being used before assignment?
You could enable tslint's only-arrow-functions
and then replace your function getValue()
with
const getValue = function(): string {
return value;
}
or even
const getValue = (): string => value;
At that point your first line will be a compiler error:
Block-scoped variable 'getValue' used before its declaration