So I have been playing around with other approaches to the workaround described here. The first thing I tried was:
Interestingly enough, this approach works well in another scenario:
In this scenario you won’t get Intellisense for x above the if statement because Visual Studio does not perform return type analysis. However, using the same trick, you can see that you get Intellisense after the if statement. This makes life better in a number of scenarios. However, it does litter your code a bit. Use it at your discretion:). One could write a little utility that scans .js files and removes these entries based on a regular expression. Maybe we’ll look at writing something such a utility for our next release.