fix(core): use PageProps instead of FreshContext in define*() compat functions (#3064)
In Fresh 1, define apps used `RouteContext`, which align with `PageProps` in Fresh 2, rather than `FreshContext`. E.g. before this PR, one would get a type error if they tried to use `ctx.Component` within `defineApp()` and now they shouldn't.
This commit is contained in:
+2
-2
@@ -1,10 +1,10 @@
|
||||
import type { FreshContext } from "./context.ts";
|
||||
import type { PageProps } from "./context.ts";
|
||||
import { assertType, type IsExact } from "@std/testing/types";
|
||||
import { expect } from "@std/expect";
|
||||
import { type defineApp, type defineLayout, defineRoute } from "./compat.ts";
|
||||
|
||||
Deno.test("compat - defineFn works", () => {
|
||||
const ctx = {} as FreshContext<unknown>;
|
||||
const ctx = {} as PageProps<unknown>;
|
||||
expect(defineRoute(() => new Response("test"))(ctx)).toBeInstanceOf(Response);
|
||||
expect(defineRoute(() => <span>test</span>)(ctx)).toBeInstanceOf(Object);
|
||||
expect(defineRoute(() => null)(ctx)).toEqual(null);
|
||||
|
||||
Reference in New Issue
Block a user