TypeScript allows editors to perform automated refactors which are aware of the rules of the languages.
Here, for instance, Visual Studio Code is able to rename references to the inner foo without altering the outer foo. This would be difficult to do with a simple find/replace.