Rather dangerous feature of being able to return undefined instead of whatever return type the function has.

Topics: General, Language Specification
Feb 17, 2014 at 8:03 PM
Full story here: https://typescript.codeplex.com/workitem/2186

Consider the following example:
function a(): string {
return 
 '';
}

var x = a(); // x is string
the generated code looks like this:

function a(){
return;
 '';
}
So despite the obvious problem compiler closes its eyes on it. I think this is behavior dangerous and leads to unintended hard-to-be-spotted bugs.
Coordinator
Feb 18, 2014 at 3:01 PM
Since it's valid JavaScript, just something you might not want to do accidentally, this would be something a linter should help with. There are already some TypeScript linters (tslint from Palantir: https://github.com/palantir/tslint is one that comes to mind), and there may be options there to check for automatic semicolons.
Feb 18, 2014 at 10:18 PM
tslint can enforce statement semicolons with the semicolon rule. In this case, it would've also warned about unreachable code for the line with the empty string via the no-unreachable rule.
Feb 19, 2014 at 11:01 AM
@ashwinraman9, TSLint is looking very promising.

There doesn't appear to be a way of incorporating it in Visual Studio - without using Web Essentials. Web Essentials is great but it's not everyone's cup of tea.

I wonder if the people responsible for the TypeScript Visual Studio plugin have plans to provide TS Lint for Visual Studio users?