Circular function expressions

Fixes #445 and #583.

Function expression bodies are now checked in a separate phase after all statements in the enclosing body to ensure constructs like the following are correctly typed:
```typescript
var foo = function () {
    var s = foo();
    return "hello";
}
```
Previously we'd perform a full type check of the body of the function expression whilst in the process determining the type of `foo` which would cause `foo` to be given type `any` because of the recursive reference. With this change, `foo` is now correctly typed as `() => string`.
Logged #611