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

Type of loaderData or actionData is corrupted if return redirectWith...(...) #35

Open
tats-u opened this issue Jan 7, 2025 · 3 comments

Comments

@tats-u
Copy link

tats-u commented Jan 7, 2025

Related:

If return redirectWith...(...) is used in action or loader, the type of actionData or loaderData in the component will be corrupted and contaminated with Response.
The type of the original redirect in React Router has been fixed in 7.1.0 by the following PR:

Therefore, you should upgrade React Router as devDependencies and peerDependencies to 7.1.0 or later.

@tats-u
Copy link
Author

tats-u commented Jan 7, 2025

npm i -D react-router@^7.1.1
npm run build
DTS Build start
src/index.ts(139,14): error TS4023: Exported variable 'createToastUtilsWithCustomSession' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.
src/index.ts(219,14): error TS4023: Exported variable 'redirectWithToast' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.
src/index.ts(237,14): error TS4023: Exported variable 'redirectWithError' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.
src/index.ts(248,14): error TS4023: Exported variable 'redirectWithSuccess' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.
src/index.ts(259,14): error TS4023: Exported variable 'redirectWithWarning' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.
src/index.ts(270,14): error TS4023: Exported variable 'redirectWithInfo' has or is using name 'redirectSymbol' from external module "I:/remix-toast/node_modules/react-router/dist/development/route-data-aSUFWnQ6" but cannot be named.

Error: error occured in dts build
    at Worker.<anonymous> (I:\remix-toast\node_modules\tsup\dist\index.js:2294:26)
    at Worker.emit (node:events:524:28)
    at MessagePort.<anonymous> (node:internal/worker:267:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
DTS Build error
RollupError: Failed to compile. Check the logs above.
    at error (I:\remix-toast\node_modules\rollup\dist\shared\rollup.js:353:30)
    at Object.error (I:\remix-toast\node_modules\rollup\dist\shared\rollup.js:1721:20)
    at Object.error (I:\remix-toast\node_modules\rollup\dist\shared\rollup.js:25627:42)
    at generateDtsFromTs (I:\remix-toast\node_modules\tsup\dist\rollup.js:7512:22)
    at I:\remix-toast\node_modules\tsup\dist\rollup.js:7519:59
    at _nullishCoalesce (I:\remix-toast\node_modules\tsup\dist\rollup.js:1:198)
    at Object.transform (I:\remix-toast\node_modules\tsup\dist\rollup.js:7519:18)
    at I:\remix-toast\node_modules\rollup\dist\shared\rollup.js:1914:40

@tats-u
Copy link
Author

tats-u commented Jan 8, 2025

Proven that we don't have to take an action for this issue
Will be fixed in a future release

@AlemTuzlak
Copy link
Contributor

yeah this seems like a react-router issue for sure, especially the 2nd comment you made. Please keep me posted on if this fixes it for you after they merge it!

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

No branches or pull requests

2 participants