Skip to content
Source
Sign inSign up
TanStack/pacer

Incorrect inferred type for the async functions #156

Closedghostd(GitHub profile, opens in a new tab) opened this issue 1 comment

TanStack Pacer version

0.19.4

Framework/Library version

React 18

Describe the bug and the steps to reproduce it

Some async functions have incorrect inferred types.

    const debouncedCallback = useAsyncDebouncedCallback(
        async (value: string): Promise<string> => {
            return "fake network result " + value
        },
        {
            wait: 500,
        }
    )
    // debouncedCallback:  (value: string) => Promise<Promise<string>>

    const throttledCallback = useAsyncThrottledCallback(
        async (value: string): Promise<string> => {
            return "fake network result " + value
        },
        {
            wait: 500,
        }
    )
    // throttledCallback:  (value: string) => Promise<Promise<string>>

    const rateLimitedCallback = useAsyncRateLimitedCallback(
        async (value: string): Promise<string> => {
            return "fake network result " + value
        },
        {
            limit: 5,
            window: 60000,
            windowType: 'sliding',
        }
    )
    // rateLimitedCallback:  (value: string) => Promise<Promise<string>>

.

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Yes, I am also opening a PR that solves the problem along side this issue

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. gnunesdev(GitHub profile, opens in a new tab)commented

    Just tried to use the useAsyncRateLimitedCallback fn on react adapter 0.20.0 version and got the same problem. I'll use for now the standard version, but it'd be great to have it fixed!

  2. KevinVandy closed this

Sign in to join this conversation.