Comments (8)
@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.
@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.
Here's a couple of implementations found in type-fest discussions:
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.
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.
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.
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.
@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.
Thanks @kiliman @brookslybrand @KubaJastrz
from remix.
Related Issues (20)
- vite cjsInterop SyntaxError with MUI HOT 1
- Symbols decoding issue HOT 2
- Nested route ErrorBoundaries can cause "Unexpected Server Error" during SSR, if error is thrown below Outlet
- ErrorBoundary hydration fails in development if there are any elements in head after Links
- Remix Cloudflare builds should not work on based on the `/functions` directory HOT 3
- Quirrel is not working with the latest Remix Build HOT 1
- Using `as const` on an enum triggers typescript errors on `unstable_defineLoader`
- Using Suspense + Await to resolve deferred loader data breaks pending UI when navigating within the same route HOT 1
- Using React.lazy for a component can cause the styles to disappear when navigating to another route with the same component.
- Material UI breaks Remix SPA build (but works fine in regular Remix apps) HOT 4
- createFileSessionStorage not working HOT 1
- flat is not function when run i android 9 HOT 8
- playground template Error HOT 1
- 'Possibly Infinite' type when attempting to use new Single Fetch types HOT 1
- Opt out from scroll restoration on a per Link basis HOT 3
- Double clicking on <Link to={} /> makes several requests to the parent routes HOT 1
- forwarding of request cookie headers comma separated instead of semi-colon separated HOT 1
- Hydration failed sometimes not always, the diff remixDevTools shows almost is about style attribute.
- Remix serve crashes with pm2 in cluster mode HOT 5
- @remix-run/express ipv6 only crash! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remix.