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

RxJs debounce type is wrong #4428

Open
Yohandah opened this issue Mar 30, 2023 · 1 comment
Open

RxJs debounce type is wrong #4428

Yohandah opened this issue Mar 30, 2023 · 1 comment
Labels
bug libdef Related to a library definition

Comments

@Yohandah
Copy link

CLI Version

3.3.1

Operating system

macOS Ventura

Bug description

The type definition for RxJs's debounce is not correct.

As the RxJs docs says :

const debouncedExample = example.pipe(debounce(() => timer(1000)));

but when you perform it in a flow app, the following error triggers

Flow: Cannot call debounce with function bound to durationSelector because number [1] is incompatible with mixed [2] in type argument T [3] of the return value. [1] number: flow-typed/npm/rxjs_v6.x.x.js:769 [2] mixed: flow-typed/npm/rxjs_v6.x.x.js:1791 [3] T: flow-typed/npm/rxjs_v6.x.x.js:36

Steps to reproduce

  1. install rxjs on a flow project
  2. add .pipe(debounce(() => timer(1000))); to an observable
  3. the error triggers

Error output/screenshots

image

Flow configuration

[version]
^0.188
[include]
./js/.
[declarations]
<PROJECT_ROOT>/node_modules/*
[untyped]
<PROJECT_ROOT>/vendor/symfony/*
<PROJECT_ROOT>/public/*
<PROJECT_ROOT>/.build/.*
<PROJECT_ROOT>/.cdn/.*
[libs]
[options]
sharedmemory.hash_table_pow=21
autoimports=false
module.system=node
react.runtime=automatic
module.name_mapper='^(containers|components|constants)/(.)$' -> '<PROJECT_ROOT>/js/\1/\2'
module.name_mapper='^\com.myapp/(.
)$' -> '<PROJECT_ROOT>/js/modules/\1'
module.name_mapper='^\com.myapp.redux/(.)$' -> '<PROJECT_ROOT>/js/redux/\1'
module.name_mapper='^\com.myapp.common/(.
)$' -> '<PROJECT_ROOT>/js/common/\1'

Anything else?

I have found that when I modify the type from

declare export function debounce<T>(
    durationSelector: (value: T) => rxjs$SubscribableOrPromise<mixed>
  ): rxjs$MonoTypeOperatorFunction<T>

to

declare export function debounce<T>(
    durationSelector: (value: T) => rxjs$ObservableInput<any>
  ): rxjs$MonoTypeOperatorFunction<T>

it works. I could do a PR but I'm not sure on how this project works, I would have to modify the type in EVERY version of RxJS definition where it's defined ?

Do you want to submit a pull request to fix this bug?

Yes, but need help

@Yohandah Yohandah added bug cli Related to CLI tool labels Mar 30, 2023
@Brianzchen Brianzchen added libdef Related to a library definition and removed cli Related to CLI tool labels Jun 3, 2023
@Brianzchen
Copy link
Member

Hi apologies for the late reply. The change is pretty simple to do and you can read about how to contribute here

rxjs defs are currently throwing a bunch of errors though so hard to tell if your update would break existing tests. I'll look into cleaning up so you we can try make this update. Will keep you posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug libdef Related to a library definition
Projects
None yet
Development

No branches or pull requests

2 participants