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

update dependencies and code #1032

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

peaBerberian
Copy link
Collaborator

This is the usual dependency update before a release (scheduled to be the v3.26.2).

After updating typescript-eslint, new linter errors made their apparitions, for cases where an any type is used as a function argument (the rule in question is no-unsafe-argument).

That's a rule we want (any is bad after all!) but RxJS, our main dependency, does not respect it well.
Especially, some operators which transform an observable into another without needing to look at the items of the source Observable (e.g. mapTo, mergeMapTo, switchMapTo, ignoreElements) have an any in their type definition for the type of the source Observable's elements (where an unknown would actually suffice and be type-safe).

Replacing on their side this any by unknown is planned for their 8.x.x release (which is not yet released). In the meantime, we had to find a solution.

I chose to do two things:

  1. Replace all the "***To" (mapTo, mergeMapTo and so on) operators by their callback-based equivalent (map, mergeMap and so on). I did that mostly because RxJS devs seems to plan deprecating the ***To operators anyway in profit of the callback-based ones.

  2. For the last remaining operator, ignoreElements(), I just disabled the rule with a long comment attached on top of each case.

@peaBerberian peaBerberian added this to the 3.26.2 milestone Dec 15, 2021
@peaBerberian peaBerberian force-pushed the misc/dependencies-update-rxjsv7.4.0 branch 3 times, most recently from ca0f0bc to 07b88fa Compare December 15, 2021 16:07
This is the usual dependency update before a release (scheduled
to be the v3.26.2).

After updating `typescript-eslint`, new linter errors made their
apparitions, for cases where an `any` type is used as a function
argument (the rule in question is
[no-unsafe-argument](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-argument.md)).

That's a rule we want (`any` is ___bad___ after all!) but RxJS,
our main dependency, does not respect it well.
Especially, some operators which transform an observable into
another without needing to look at the items of the source
Observable (e.g. `mapTo`, `mergeMapTo`, `switchMapTo`,
`ignoreElements`) have an `any` in their type definition for the type
of the source Observable's elements (where an `unknown` would actually
suffice and be type-safe).

Replacing on their side this `any` by `unknown` is planned for their
8.x.x release (which is not yet released). In the meantime, we had to
find a solution.

I chose to do two things:

  1. Replace all the "***To" (`mapTo`, `mergeMapTo` and so on)
     operators by their callback-based equivalent (`map`,
     `mergeMap` and so on).
     I did that mostly because RxJS devs [seems to plan
     deprecating the ***To operators anyway in profit of the
     callback-based ones](ReactiveX/rxjs#6399).

  2. For the last remaining operator, `ignoreElements()`, I just
  disabled the rule with a long comment attached on top of each case.
@peaBerberian peaBerberian force-pushed the misc/dependencies-update-rxjsv7.4.0 branch from 07b88fa to 8a49c7c Compare December 15, 2021 16:09
@peaBerberian peaBerberian merged commit e65c993 into master Dec 17, 2021
@peaBerberian peaBerberian deleted the misc/dependencies-update-rxjsv7.4.0 branch August 13, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant