You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code
// Below I am returning Observable, but I've tried returning a pure callback function and it doesn't work either.
interfaceIIdProvider{readonlyidToken$: Observable<string>;readonlyproviderURL: string;}publicgetLastIdProvider(): IIdProvider|null;publicisAuthenticated(): boolean|Observable<boolean>{let idProvider =this.getLastIdProvider();if(idProvider===null)returnfalse;idProvider.idToken$.subscribe(x=>console.log(x));// OKreturnObservable.create(observer=>{idProvider.idToken$// TS2531: Object is possibly null.subscribe(x=>console.log(x));
....// for Pure callback function version:publicisAuthenticated(): boolean|(()=>void){let idProvider =this.getLastIdProvider();if(idProvider===null)returnfalse;idProvider.idToken$//OK.subscribe(x=>console.log(x));return()=>{idProvider.idToken$.subscribe(x=>console.log(x));// TS2531: Object is possibly null};
Expected behavior:
both the idProvider should be null following control flow based type analysis.
Actual behavior:
The second one inside an observable creating function prompts warning of 'possibly null'
The text was updated successfully, but these errors were encountered:
goldenbearkin
changed the title
Control flow based type analysis not working inside an returning function
Control flow based type analysis not working inside an callback function
Jul 31, 2016
TypeScript Version: nightly (2.0.0)
Code
// Below I am returning Observable, but I've tried returning a pure callback function and it doesn't work either.
Expected behavior:
both the idProvider should be null following control flow based type analysis.
Actual behavior:
The second one inside an observable creating function prompts warning of 'possibly null'
The text was updated successfully, but these errors were encountered: