-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed as not planned
Labels
Description
Reproduction
Type safety seems messed up when returning data
utility function from action/loader.
export const loader = async ({ request }: LoaderFunctionArgs) => {
...
return data(mapped, {
headers: {
'Cache-Control': 'max-age=900, s-maxage=900, stale-while-revalidate=31536000'
}
})
}
export const VideosListPage = () => {
const data = useLoaderData<typeof loader>()
console.log(data[0]?.title)
...
}

Basically if you return data()
from loader/action, the type of const data = useLoaderData<typeof loader>()
will incorrectly be of DataWithResponseInit
.
The typescript LSP will suggest properties like .data
etc are available, but they don't work as that's not actually what is returned.
Searching this repo, there are other similar issues, but they are marked as closed/fixed. Which doesn't make sense, as the issue is definitely not fixed.
- useLoaderData types broken if unstable_data is conditionally used #9826
- Single fetch typesafety when using
unstable_data
conditionally #9998
System Info
System:
OS: macOS 15.2
CPU: (10) arm64 Apple M1 Max
Memory: 1.76 GB / 64.00 GB
Shell: 3.7.1 - /opt/homebrew/bin/fish
Binaries:
Node: 22.11.0 - ~/.nodenv/versions/22.11.0/bin/node
npm: 10.9.0 - ~/.nodenv/versions/22.11.0/bin/npm
Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 130.1.71.121
Chrome: 131.0.6778.140
Edge: 131.0.2903.99
Safari: 18.2
npmPackages:
@remix-run/dev: ^2.15.1 => 2.15.1
@remix-run/eslint-config: ^2.15.1 => 2.15.1
@remix-run/node: ^2.15.1 => 2.15.1
@remix-run/react: ^2.15.1 => 2.15.1
@remix-run/route-config: ^2.15.1 => 2.15.1
@remix-run/serve: ^2.15.1 => 2.15.1
vite: ^5.1.0 => 5.4.8
Used Package Manager
npm
Expected Behavior
Types should be returned correctly
Actual Behavior
Types returned incorrectly
wong2, DarkIntaqt, fiws, 9001-Sols, elkelk and 1 more