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

Typescript Operator Definition Incorrect? (map) #2272

Closed
sam-s4s opened this issue Jan 12, 2017 · 9 comments
Closed

Typescript Operator Definition Incorrect? (map) #2272

sam-s4s opened this issue Jan 12, 2017 · 9 comments

Comments

@sam-s4s
Copy link

sam-s4s commented Jan 12, 2017

RxJS version:
5.0.1

Code to reproduce:
let obs = Observable.of(1, 2, 3);
let m = obs.map((n: number) => n + 1); // Yields error - "Supplied parameters do not match any signature of call target."

Expected behavior:
Code should compile.

Actual behavior:
Code yields the error "Supplied parameters do not match any signature of call target."

Additional information:
This used to work correctly using rxjs 5.0.0-beta.12.

In version 5.0.1, the type definition file (map.d.ts) contains the following signature:

export declare function map<T, R>(this: Observable<T>, project: (value: T, index: number) => R, thisArg?: any): Observable<R>;

However, the javascript file contains the following signature:

function map(project, thisArg) {

I know very little of the context behind the changes in rxjs, but it appears that the addition of the "this: Observable" parameter in the new signature is causing the problem, as when this parameter is removed, the problem goes away... (and both the parameter and the problem were not present in 5.0.0-beta.12).

I've checked, and it appears that all of the other operators also have this additional parameter in the new version (and thus none of them work).

It appears to make all operators in rxjs completely unusable.

I'm not sure if it's something I'm doing wrong, or if someone's stuffed up the type definition files? And I'm surprised that this (breaking change) hasn't stopped everyone else from using rxjs, too... which makes me wonder if it's just me!

Any help with this would be greatly appreciated!

@trxcllnt
Copy link
Member

@sam-s4s I believe this was a new feature added by TS 2.0. Are you using an older version of the TS compiler? cc'ing @kwonoj or @david-driscoll, who have more context about these sorts of changes.

@sam-s4s
Copy link
Author

sam-s4s commented Jan 12, 2017

@trxcllnt Interesting! Thanks for the reply Paul :)

I am using "typescript": "2.0.10", so you wouldn't think it could be that?

@kwonoj
Copy link
Member

kwonoj commented Jan 12, 2017

@david-driscoll
Copy link
Member

@sam-s4s what editor are you using? As @kwonoj points out it's working with 2.0.10 normally, and we have not yet jumped onto TypeScript 2.1 yet ourselves.

@kwonoj
Copy link
Member

kwonoj commented Jan 12, 2017

I was picking 2.0.1 to match with issue, but for me 2.1 also worked.

@sam-s4s
Copy link
Author

sam-s4s commented Jan 12, 2017

Ah, it can't be the editor, because I get the exact same error when I do a command line build.

So Visual Studio and the Typescript compiler both give me the same error...

I'll just try a fresh project, with nothing in it but Typescript and Rxjs...

@sam-s4s
Copy link
Author

sam-s4s commented Jan 17, 2017

Ok I got to the bottom of it :D

3 problems...

First was that the newer version of rxjs had changed, and things like map are now map<T, R>. So that was making the compiler die, and rightly so. That part is fine.

Secondly, and more the issue, the newer version of rxjs had been changed to Typescript 2, and Visual Studio 2015 did not support some of those features, so even if the code was correct, VS2015 would think it was an error (couldn't even read the types correctly).

Thirdly, annoyingly, the official angular2 website says to install Typescript 2 for VS2015, but links to an installer that actually completely breaks TS support in VS2015... Awesome. I've made a github issue for that here: angular/angular.io#3102

So the overall solution to the problem, just in case anyone read this and has the same problem, is that you do need to install Typescript 2 for VS2015, but at the time of posting, that can be found here:
Page link: https://www.microsoft.com/en-us/download/details.aspx?id=48593
Direct link: http://download.microsoft.com/download/6/D/8/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA/TS2.1-dev14update3-20170111.1/TypeScript_Dev14Full.exe

So install that, fix the dual typed issue, and all is good :)

@kwonoj
Copy link
Member

kwonoj commented Jan 17, 2017

Yes, visual studio has its own toolset and you need to reconfigure it, compare to other editors does honor npm installed local modules. (i.e #1696) . VS2017 might resolve this issues better.

Closing issue as resolved for now.

@kwonoj kwonoj closed this as completed Jan 17, 2017
@lock
Copy link

lock bot commented Jun 6, 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 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants