-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update typing for TypeScript 1.7 "polymorphic this typing" #846
Comments
I was interested in this topic bit while ago when introduced 1.8 dev of typescript in RxJS, hit couple of roadblocks at the moment. :
causes compiler complains about type inferences like polymorphic
: polymorphic
can't be converted to return
: type transformed output
Still, I'm feeling this is great feature and would explore way to adopt into RxJS. bit more details about polymorphic this can be found at https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#this-typing |
Note : it is completely possible I'm not fully knowledgeable about this feature and above comment could be wrong for some aspect. Above comments are based on my initial exploration. |
That's too bad. I'll close this for now, then. And perhaps file an issue with TypeScript for our specific use case/needs. |
Thanks to @trxcllnt for pointing this out:
http://blogs.msdn.com/b/typescript/archive/2015/11/30/announcing-typescript-1-7.aspx
Basically, since our operators can return different types due to the snazzy lift architecture, we should be returning
: this
and not: Observable<T>
from them.... this might get a little nutty when it comes to types that change the generic output, though.
map
for example.Observable<T>.prototype.map((x: T) => R): Observable<R>
would beObservable<T>.prototype.map((x: T) => R): this
... I'm not sure hot TypeScript will suss out thatthis
should be generically typed toR
and notT
...The text was updated successfully, but these errors were encountered: