Giter Club home page Giter Club logo

Comments (8)

kiliman avatar kiliman commented on June 28, 2024 1

@tomiwaajayi either stop using defineLoader or override it to support your requirements.

This function is there just to help with types. It's not a requirement.

from remix.

brookslybrand avatar brookslybrand commented on June 28, 2024 1

@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 interface. You can do this through type utilities or by rewriting the type

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

from remix.

KubaJastrz avatar KubaJastrz commented on June 28, 2024 1

Here's a couple of implementations found in type-fest discussions:

> playground <

But beware, none of them happen to be exported from type-fest/index.d.ts at the moment. Don't know if by mistake or by design, because I found ConditionalSimplifyDeep in their source code.

from remix.

tomiwaajayi avatar tomiwaajayi commented on June 28, 2024

I have a similar issue.
I am using the unstable_defineLoader fn which is meant to improve type safety (according to the docs)

my loader returns this

return { store, cart, ENV: getEnv(), userPrefs: userPrefsCookie, transactionRef, }

And I get errors that saying cart is not of type Serializable

from remix.

KubaJastrz avatar KubaJastrz commented on June 28, 2024

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 type over interface, although that is not always possible (my original issue is caused by an interface imported from 3rd party package 😢).

More cases in the > playground <.

EDIT: I added more mixed cases, it seems like it has to be all type: > playground <

from remix.

brookslybrand avatar brookslybrand commented on June 28, 2024

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

from remix.

tomiwaajayi avatar tomiwaajayi commented on June 28, 2024

@brookslybrand
Is there any temp fix for this ?

Or we'd have to wait for some update from the remix team.

For context:
We have a types repo shared by backend team and frontend team.
So it's basically impossible for us to change all interfaces to type.

from remix.

tomiwaajayi avatar tomiwaajayi commented on June 28, 2024

Thanks @kiliman @brookslybrand @KubaJastrz

from remix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.