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:
Asher Gomez
2025-06-27 09:54:53 +02:00
committed by GitHub
parent 0b6e62a693
commit 8f813fad90
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -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);