Of particular note is the change to
`tests/fixture_plugin/routes/test.tsx`. Note how I do this:
```diff
- async GET(_req, ctx: HandlerContext<unknown, { test: string }>) {
+ async GET(_req, ctx: FreshContext<{ test: string }, unknown>) {
```
I find it strange and confusing that the order of the type parameters
has "changed". This makes it impossible to do a simple search and
replace, because people now have to change order as well.
Most of the types have been declared as `<T, S>`, i.e. data before
state:
* `PageProps<T = any, S = Record<string, unknown>>`
* `RouteContext<T = any, S = Record<string, unknown>>`
* `Handler<T = any, State = Record<string, unknown>>`
* `Handlers<T = any, State = Record<string, unknown>> `
* `AsyncRoute<T = any, S = Record<string, unknown>>`
* `PageComponent<T = any, S = Record<string, unknown>> `
* `AsyncLayout<T = any, S = Record<string, unknown>>`
And then `FreshContext` comes around like
```
export interface FreshContext<
State = Record<string, unknown>,
// deno-lint-ignore no-explicit-any
Data = any,
NotFoundData = Data,
>
```
and switches it all up.
Not a huge issue, but just something to be aware of that others might
report.
20 lines
459 B
TypeScript
20 lines
459 B
TypeScript
import { PageProps } from "$fresh/server.ts";
|
|
|
|
type Data = { hello: string };
|
|
type State = { root: string };
|
|
|
|
export default function NotFoundPage(
|
|
{ data, state, url }: PageProps<Data | undefined, State>,
|
|
) {
|
|
// Checks that we have the correct type for state
|
|
state.root satisfies string;
|
|
|
|
return (
|
|
<>
|
|
<p>404 not found: {url.pathname}</p>
|
|
{data?.hello && <p>Hello {data.hello}</p>}
|
|
<p>State root: {state.root}</p>
|
|
</>
|
|
);
|
|
}
|