-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
'redirectSymbol' introduced in #12527 causes type error #12615
Comments
I am also encountering this TypeScript issue. This error occurs when any functions return a redirect call. Here is my related Discord message + thread: https://discord.com/channels/770287896669978684/1319889604211511384. Here are my TypeScript configs: tsconfig.json {
"files": [],
"references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.vite.json" }],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"paths": {
"~/*": ["./app/*"]
}
}
} tsconfig.node.json {
"extends": "./tsconfig.json",
"include": [
"react-router.config.ts",
"tailwind.config.ts",
"vite.config.ts",
"vitest.workspace.ts",
"prisma/**/*.ts"
],
"compilerOptions": {
"composite": true,
"strict": true,
"types": ["node"],
"lib": ["ES2022"],
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
} tsconfig.vite.json {
"extends": "./tsconfig.json",
"include": [
".react-router/types/**/*",
"app/**/*",
"app/**/.server/**/*",
"app/**/.client/**/*",
"server/**/*",
"env.d.ts",
"tests/**/*.ts",
"types.ts"
],
"compilerOptions": {
"composite": true,
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"types": ["vite/client"],
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"baseUrl": ".",
"rootDirs": [".", "./.react-router/types"],
"typeRoots": ["public/node_modules/@types", "./node_modules"],
"esModuleInterop": true,
"resolveJsonModule": true
}
} |
I can't reproduce this locally. Could you share a repro on stackblitz or github? |
@pcattori I figured out that the issue occurs when the |
@pcattori here's a branch of the repo where I'm encountering this issue. As @penspinner observed, it is happening when a redirect is returned from a loader/action. I don't seem to have Presumably I could get around this by throwing the redirect instead of returning it, but the docs seem to encourage returning. |
@pcattori Hi, facing same issue with RR7 as framework. When i am removing return from redirect, the error is going away. This is the exact message
|
Experienced the same thing. @pcattori if you want a very minimal reproduction repository, made one here - https://github.com/AdiRishi/rr7-redirect-ts-bug The error can be seen by running |
I have exactly the same issue. :/ |
@AdiRishi looking at your reproduction (https://github.com/AdiRishi/rr7-redirect-ts-bug), I commented out @dantrain looks like your Closing since those were the two reproductions provided so far, but if anyone disagrees with my reasoning or has a reproduction without compiler-only settings like |
I'm currently running into this without any of those settings. I don't have a reproducible version at the moment. I'll try and make a version in the next few days. |
Thank you for looking into this @pcattori, I overrode these as you suggested and the problem is solved for me. I wondered why I had added these library only options to my base |
I tried setting
https://www.typescriptlang.org/tsconfig/#composite I'm using project references and it requires |
I have the same issue/constraint @penspinner mentioned. For now, I'm working around it using the same code
I also considered using |
Also arrived here from the templates. A minimal reproduction: npx create-react-router@latest ./reproduction \
--template remix-run/react-router-templates/node-custom-server --yes Edit + import { redirect } from "react-router"; export async function loader({ context }: Route.LoaderArgs) {
+ return redirect("example.org"); TypeScript error on
|
I'm using React Router as a...
framework
Reproduction
Run
tsc
System Info
System: OS: macOS 15.1.1 CPU: (10) arm64 Apple M1 Pro Memory: 139.30 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.11.0 - /usr/local/bin/node npm: 10.9.0 - /usr/local/bin/npm pnpm: 9.15.0 - ~/Library/pnpm/pnpm Watchman: 2024.10.07.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 131.0.6778.205 Safari: 18.1.1
Used Package Manager
pnpm
Expected Behavior
No type errors
Actual Behavior
Received error:
The text was updated successfully, but these errors were encountered: