-
Notifications
You must be signed in to change notification settings - Fork 2.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
Single Fetch: TypeScript implementation of defineLoader doesn't support records with arrays #9514
Comments
I have a similar issue. my loader returns this
And I get errors that saying cart is not of type Serializable |
I entered a little rabbit hole and all roads lead to this: microsoft/TypeScript#50087 (comment) It seems like this is an intended mechanic in TS. Workaround would be to use
EDIT: I added more mixed cases, it seems like it has to be all |
Yep, I ran into this too, and @pcattori confirmed exactly what you said Thanks for adding the types. Definitely a problem for 3rd party packages like you mentioned |
@brookslybrand Or we'd have to wait for some update from the remix team. For context: |
@tomiwaajayi either stop using This function is there just to help with types. It's not a requirement. |
@tomiwaajayi we're currently looking into good options/tradeoffs A temporary fix would be to rework your type in way to where it undoes it's definition as an For example, if you have an interface like interface BlogPost {
title: string;
authors: { name: string }[];
} Pick<BlogPost, 'title' | 'authors'> will get it to work. That's not a perfect solution by any means, nor the officially recommended one, but remember that Single Fetch is still an unstable API, so right now any suggestions I have are going to be a hack around the final solution |
Here's a couple of implementations found in type-fest discussions: But beware, none of them happen to be exported from |
Thanks @kiliman @brookslybrand @KubaJastrz |
Reproduction
I copied the implementation of
Serializable
into TypeScript playground. Let me know if you want me to submit an actual reproduction with loader code.https://www.typescriptlang.org/play/?#code/C4TwDgpgBAyhBOBLAhgG0QL2QI1dAvFAK4B2AJhAGaIkRlQA+UJRqqjU2A9l3siRwDOwJCQDmQkAFtu7JixkIOAQXjxkIADxwkaTDjwA+DgG8AUFCgBtANYQQALigAFeF0jxQAaXsBdJzoo6Fi4EADcZgC+HNiIYjTAHAAiyMDQTACqAEoAMhxZEGIAogAeYBxFalzwHACyyGDaCEH6oQA0sM16IUYccMBNusEGEMZMrlxSiIIQgy09oxFmZgkIlMgAxtApwMhQ5pbowk4508AAkmlSVr4RkSskafDrW1CnwpcQUvsWUIhkTmEojEd2WFA2qGQ8GgGy4JGEUDIqWQTh2yGWAHoMVBlIJBHESDQJGQuBBBCQAOSJADu1RsUAcGLMsPhiWwyABnSGrTwUEISN2SyxUHqYDARKgtPgNkEUAA-HLmXCEWIeJzAt0Rnyfoczk4BcgAHRHYCGqQNAAUFsQVwAlHzjBaDpY-pybV9Df82r9Irbbd7IkA
System Info
Used Package Manager
pnpm
Expected Behavior
No TypeScript errors
Actual Behavior
TypeScript error:
The text was updated successfully, but these errors were encountered: