Skip to content
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

ajax() type signature error (TS) when string provided #1382

Closed
staltz opened this issue Feb 23, 2016 · 4 comments · Fixed by #1383
Closed

ajax() type signature error (TS) when string provided #1382

staltz opened this issue Feb 23, 2016 · 4 comments · Fixed by #1383
Labels
help wanted Issues we wouldn't mind assistance with. TS Issues and PRs related purely to TypeScript issues

Comments

@staltz
Copy link
Member

staltz commented Feb 23, 2016

John Lindquist reported that

import {Observable} from 'rxjs/Rx.DOM';
Observable.ajax('http://swapi.co/api/people/1/')
    .subscribe();

gives TS compile error

ERROR in ./src/main.ts
(2,1): error TS2346: Supplied parameters do not match any signature of call target.

Solution suggestion:
I think the type signature should be changed like this:

 export interface AjaxCreationMethod {
-  (): <T>(urlOrRequest: string | AjaxRequest) => Observable<T>;
+  <T>(urlOrRequest: string | AjaxRequest): Observable<T>;
   get: <T>(url: string, resultSelector?: (response: AjaxResponse) => T, headers?: Object) => Observable<T>;
   post: <T>(url: string, body?: any, headers?: Object) => Observable<T>;
   put: <T>(url: string, body?: any, headers?: Object) => Observable<T>;
   delete: <T>(url: string, headers?: Object) => Observable<T>;
   getJSON: <T, R>(url: string, resultSelector?: (data: T) => R, headers?: Object) => Observable<R>;
 }
@kwonoj
Copy link
Member

kwonoj commented Feb 23, 2016

I also noticed this while migrating test cases, simply deferred definition changes after test cases are checked in. This should be trivial changes, I'll take this up around today.

@staltz
Copy link
Member Author

staltz commented Feb 23, 2016

We really need to have TS type tests in place. Otherwise TS users might see errors like this. I suppose your #1364 will fix that?

@kwonoj
Copy link
Member

kwonoj commented Feb 23, 2016

#1364 is initial setup to prepare type definition test, so only partially covers for it (because consume definition via test cases can resolve most frequent usage). My plan is leveraging typescript-based test cases to add bunch of type definition test only check if it's written as intended - #1189 is one of examples what'll be added in further. In general, I also #1364 to be landed to start further tasks regarding type definition enhancement. Just need it to be reviewed & approved since it introduce broad number of changes along impacting development cycle.

@kwonoj kwonoj added the TS Issues and PRs related purely to TypeScript issues label Feb 23, 2016
@benlesh benlesh added the help wanted Issues we wouldn't mind assistance with. label Feb 24, 2016
kwonoj added a commit to kwonoj/rxjs that referenced this issue Feb 24, 2016
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Issues we wouldn't mind assistance with. TS Issues and PRs related purely to TypeScript issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants