Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
remix-run-bot committed May 9, 2024
1 parent dafe70e commit c650ae2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions .changeset/rotten-geckos-yawn.md
Expand Up @@ -15,18 +15,18 @@ Rather, they exist solely for typesafety by providing types for args and by ensu
```ts
export let loader = defineLoader(({ request }) => {
// ^? Request
return {a:1, b: () => 2}
return { a: 1, b: () => 2 };
// ^ type error: `b` is not serializable
})
});
```

Note that `defineLoader` and `defineAction` are not technically necessary for defining loaders and actions if you aren't concerned with typesafety:

```ts
// this totally works! and typechecking is happy too!
export let loader = () => {
return {a: 1}
}
return { a: 1 };
};
```

This means that you can opt-in to `defineLoader` incrementally, one loader at a time.
Expand All @@ -35,15 +35,15 @@ You can return custom responses via the `json`/`defer` utilities, but doing so w

```ts
let loader1 = () => {
return {a: 1, b: new Date()}
}
let data1 = useLoaderData<typeof loader1>()
return { a: 1, b: new Date() };
};
let data1 = useLoaderData<typeof loader1>();
// ^? {a: number, b: Date}

let loader2 = () => {
return json({a: 1, b: new Date()}) // this opts-out of turbo-stream
}
let data2 = useLoaderData<typeof loader2>()
return json({ a: 1, b: new Date() }); // this opts-out of turbo-stream
};
let data2 = useLoaderData<typeof loader2>();
// ^? JsonifyObject<{a: number, b: Date}> which is really {a: number, b: string}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/single-fetch.md
Expand Up @@ -106,7 +106,7 @@ In order to ensure you get the proper types when using Single Fetch, we've inclu

🚨 Make sure the single-fetch types come after any other Remix packages in `types` so that they override those existing types.

** `defineLoader`, `defineAction`, `defineClientLoader`, `defineClientAction` **
\*\* `defineLoader`, `defineAction`, `defineClientLoader`, `defineClientAction` \*\*

To get typesafety when defining loaders and actions, you can use the `defineLoader` and `defineAction` utilities:

Expand Down
8 changes: 4 additions & 4 deletions packages/remix-deno/index.ts
Expand Up @@ -16,10 +16,6 @@ export {
export {
broadcastDevReady,
createSession,
unstable_defineLoader,
unstable_defineClientLoader,
unstable_defineAction,
unstable_defineClientAction,
defer,
isCookie,
isSession,
Expand All @@ -30,6 +26,10 @@ export {
redirectDocument,
unstable_composeUploadHandlers,
unstable_createMemoryUploadHandler,
unstable_defineAction,
unstable_defineClientAction,
unstable_defineClientLoader,
unstable_defineLoader,
unstable_parseMultipartFormData,
} from "@remix-run/server-runtime";

Expand Down

0 comments on commit c650ae2

Please sign in to comment.