You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{createRemixStub}from'@remix-run/testing'importtype{LoaderFunction,MetaFunction}from'@remix-run/node'constloader: LoaderFunction=async()=>({foo: 'bar'})constmeta: MetaFunction<typeofloader>=()=>[{title: 'My site'}]constRemixStub=createRemixStub([{path: '/', loader, meta },])
This results in a type error when assigning to the meta field because the loader generic in MetaFunction defaults to unknown, so typeof loader will always be incompatible with it. The type error will eventually say:
Types of property 'data' are incompatible.
Type 'unknown' is not assignable to type '<your serialized loader data>'
Proposed solution
For @remix-run/testing use MetaFunction<any>, I can't imagine needing loader types for it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Example:
This results in a type error when assigning to the
meta
field because the loader generic inMetaFunction
defaults tounknown
, sotypeof loader
will always be incompatible with it. The type error will eventually say:Proposed solution
For
@remix-run/testing
useMetaFunction<any>
, I can't imagine needing loader types for it.I'm willing to submit a PR.
Beta Was this translation helpful? Give feedback.
All reactions