Description
TypeScript Version:
1.8.0-beta
Code
return this.http.request(url, request)
.catch(initialError => {
if (initialError && initialError.status === 401 && isSecureCall === true) {
// token might be expired, try to refresh token
return me.authService.refreshAuthentication().flatMap((authenticationResult:AuthenticationResult) => {
if (authenticationResult.IsAuthenticated == true) {
// retry with new token
me.authService.setAuthorizationHeader(request.headers);
return this.http.request(url, request);
}
return Observable.throw(initialError);
});
}
else {
return Observable.throw(initialError);
}
});
Expected behavior:
This code has compiled and worked before. (this is a snippet from an angular2 application: if an authenticated request fails because the token has expired, the code tries to use a refresh token to get a new token and retry the request).
Actual behavior:
The compiler starts to hang
I have stripped down my project to the bare minimum to illustrate the problem.
To reproduce; clone this repo:
https://github.com/davyvanlaere/TypescriptCompilerIssue
Then run "npm install", followed by "tsc": the compiler will hang, and the process "Evented I/O for V8 Javascript" will start to eat memory (i let it run for a while and killed it at 1.3gb).
It has something to do with the types of the return statements. If you the replace 2nd "return this.http.request(url, request);" line with "return Observable.throw(initialError);", the compiuler will not hang.