-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Incorrect types for loader data that contain Record
types
#13058
Comments
I also experience something similar, for me it is related to sending data typed as Were you able find out why this happened to you? |
@Varkoff I'm getting a different error when I clone that repo and try to run ❯ npm run typecheck
> typecheck
> react-router typegen && tsc
error TS2688: Cannot find type definition file for '@remix-run/node'.
The file is in the program because:
Entry point of type library '@remix-run/node' specified in compilerOptions
tsconfig.json:13:15
13 "types": ["@remix-run/node", "vite/client"],
~~~~~~~~~~~~~~~~~
File is entry point of type library specified here.
Found 1 error. Not sure why that's happening, haven't dug into it. Any chance you can provide a better reproduction of your issue? |
I got rid of the issue, will present my findings below.
It all seems to come down to what is passed down to the
Just to be extra clear, all three points mentioned above had to done, just doing one or two didn't help. Hope it can help someone facing the same issues as I did. |
Am also hitting this error, and also not quite sure what to make of this yet, but here is an isolated illustration: // Changing import to use remix-run will fix the issue, so it breaks in react-router
// import {useLoaderData} from '@remix-run/react';
import {useLoaderData} from 'react-router';
type DataStructure = {
title: string;
url: string;
}
const loader = async (args) => {
const title = "Title";
const description = "desc...";
const dynamicKeyObj: {[k: string]: DataStructure} = getExternalData();
// hovering these attributes show all type values as expected
return { title, description, dynamicKeyObj };
}
const Component = () => {
const { title, description, dynamicKeyObj } = useLoaderData<typeof loader>();
// cannot use dynamicKeyObj because it is unknown
} |
@seanify-24 if I replicate your example, the type of ![]() |
@Varkoff I've condensed this into a minimal repro: https://tsplay.dev/NrkKDm So I think the fix is to remove the optionality of the internal branded type. @phryneas : heads up that I am planning to change |
Record
types
@pcattori okay, thanks for the heads-up! |
I'm using React Router as a...
framework
Reproduction
Unfortunately Stackblitz does not support Node v20. Check reproduction code here :
https://github.com/Varkoff/react-router-type-error-with-markdoc
Since upgrading to React Router v7.2.0, I've been getting this
Type 'unknown' is not assignable to type 'RenderableTreeNodes'.ts(2322)
error.Can you please take a look @pcattori ?
System Info
Used Package Manager
npm
Expected Behavior
I would like to not have the type error.
Actual Behavior
I am getting type errors, which prevent me to update code without adding @ts-ignore or @ts-expect-error flags. CI fails.
The text was updated successfully, but these errors were encountered: