New pipe operators in 5.5 fail in TS < 2.4 as they don't transfer type
See original GitHub issueRxJS version:
RxJS 5.5.0-beta.0 TypeScript 2.3
Code to reproduce:
Quite the same example as in lettable operators doc :
const source$ = range(0, 10);
source$.pipe(
filter(x => x % 2 === 0),
map(x => x.toFixed())
)
.subscribe(x => console.log(x));
Expected behavior:
It should work.
Actual behavior:
On TypeScript compilation, it fails with this error :
ERROR: Property 'toFixed' does not exist on type '{}'.
Meaning the type (here number
) is not transferred by the pipe
operator. The pipe
operator seems to default back to {}
all the time.
Additional information:
It works starting TypeScript 2.4+.
If this is normal, it should at least be indicated in the CHANGELOG, as it’s an unexpected (breaking ?) change for a minor update.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Pipe operator cannot infer return type as ... - GitHub
The problem can be solved by adding additional overload signatures to pipe , allowing for the last operator to return a ConnectableObservable ....
Read more >What could cause an error related to npm not being able to ...
Run npm start from the angular folder. Update. ASP.NET Boilerplate suggests here to use yarn because npm has some problems. It is slow...
Read more >Use the new R pipe built into R 4.1 - InfoWorld
Learn the new pipe operator built into R 4.1 and how it differs from the maggritr pipe. Don't want to install R 4.1...
Read more >Fix list for IBM WebSphere Application Server V8.5
IBM WebSphere Application Server provides periodic fixes for the base and Network Deployment editions of release V8.5. The following is a complete listing ......
Read more >Bug listing with status RESOLVED with resolution TEST ...
Bug:233 - "Emacs segfaults when merged through the sandbox." status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@cyrilletuzi we DO follow semver… the lettable operators are all new features and all existing features have not changed.
You can still use
import 'rxjs/add/operator/map';
etc in your apps with 5.5.0-beta and EVERY version of 5.x.😃
There are no breaking changes in 5.5.0
Type inference through these functions simply isn’t supported by TypeScript < 2.4, but that’s not something RxJS can control. There are, in fact, large groups of people that don’t even use TS with RxJS. We love TS and we want to support it as much as possible, but we’re not going to exclude features because older versions of TypeScript don’t handle them well.
What about following semver ?
I wouldn’t mind using a previous version of RxJS if semver was followed. What will happen in real world is that once RxJS 5.5 is released, new Angular projects (or any project using RxJS) will install RxJS 5.5 due to semver rules, and it will break in these cases. Or we’ll have to pin RxJS version and add more complicated configuration like we already have to do for TS for the exact same reason.
By the way, notice my issue doesn’t even ask for all of that. I suppose everyone is now used to quite no one really following semver. It just asks to at least write it in the docs so users know it.