This project is read-only.

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 9:03 PM
Full story here:

Consider the following example:
function a(): string {

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

function a(){
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.
Feb 18, 2014 at 4: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: is one that comes to mind), and there may be options there to check for automatic semicolons.
Feb 18, 2014 at 11: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 12:01 PM
@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?