Skip to content

[Bug]: TypeScript SetURLSearchParams type is not exported #10212

@thibaut-decherit

Description

@thibaut-decherit

What version of React Router are you using?

6.9.0

Steps to Reproduce

I have an utility class with the following function:

static updateSearchParams(
  data: {
    [key: string]: string
  },
  searchParams: URLSearchParams,
  setSearchParams: (
    nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit),
    navigateOpts?: NavigateOptions
  ) => void
) {
  setSearchParams({
    ...Object.fromEntries([...searchParams]),
    ...data
  });
}

Expected Behavior

Be able to type setSearchParams as SetURLSearchParams.

Actual Behavior

SetURLSearchParams type is not exported, I have to duplicate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions