Skip to content

Non-determinist signature results in TS2349 #9371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gjuchault opened this issue Jun 27, 2016 · 1 comment
Closed

Non-determinist signature results in TS2349 #9371

gjuchault opened this issue Jun 27, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@gjuchault
Copy link

TypeScript Version:

1.8.10

Code

Failure:

this.loginService.loginUser(user, pass)
  .subscribe(
    payload => {
      this.storageService.put('accesstoken', payload.token);
      this.storageService.put('guid', payload.guid);
      return this.loginService.fetchUserName(payload);
    },
    error => this.handleError(error)
  );

Working:

const login: Observable<any> = this.loginService.loginUser(user, pass);

login.subscribe(
    payload => {
      this.storageService.put('accesstoken', payload.token);
      this.storageService.put('guid', payload.guid);
      return this.loginService.fetchUserName(payload);
    },
    error => this.handleError(error)
  );

Definition for loginUser:

public loginUser(userName: string, password: string): Observable<LoginResponse> | Observable<Error>

Expected behavior:

No errors

Actual behavior:

TS2349: Cannot invoke an expression whose type lacks a call signature.

Notes
It comes from the | operator in the loginUser function. If I switch to a "determinist" type by putting Observable<any>, typescript is some way "sure" (sorry for the term) of having an observable and it accepts the subscribe call.

@gjuchault gjuchault changed the title Chaining results in TS2349 Non-determinist signature results in TS2349 Jun 27, 2016
@Arnavion
Copy link
Contributor

See #4612

@mhegazy mhegazy closed this as completed Jun 27, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 27, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants