feat: export compat types from /compat export (#2478)

This commit is contained in:
Luca Casonato
2024-06-03 14:32:38 +00:00
committed by GitHub
parent 2fb8606e9e
commit aa19b393e7
10 changed files with 186 additions and 143 deletions
+13
View File
@@ -0,0 +1,13 @@
// Compat with older Fresh versions
export {
type AppProps,
defineApp,
defineLayout,
defineRoute,
type ErrorPageProps,
type Handler,
type Handlers,
type LayoutProps,
type RouteContext,
type UnknownPageProps,
} from "./server.ts";
+25 -11
View File
@@ -1,33 +1,47 @@
import type { VNode } from "preact";
import type { FreshContext } from "../context.ts";
import type { HandlerByMethod } from "../handlers.ts";
import type { HandlerFn, RouteHandler } from "../handlers.ts";
/**
* @deprecated Use {@link FreshContext} instead
* @deprecated Use {@link PageProps} instead.
*/
export type AppProps<_Data = unknown, T = unknown> = FreshContext<T>;
/**
* @deprecated Use {@link FreshContext} instead
* @deprecated Use {@link PageProps} instead.
*/
export type LayoutProps<_Data = unknown, T = unknown> = FreshContext<T>;
/**
* @deprecated Use {@link FreshContext} instead
* @deprecated Use {@link PageProps} instead.
*/
export type UnknownPageProps<_Data = unknown, T = unknown> = FreshContext<T>;
/**
* @deprecated Use {@link FreshContext} instead
* @deprecated Use {@link PageProps} instead.
*/
export type ErrorPageProps<_Data = unknown, T = unknown> = FreshContext<T>;
/**
* @deprecated Use {@link FreshContext} instead
* @deprecated Use {@link FreshContext} instead.
*/
export type RouteContext<_T = never, S = Record<string, unknown>> =
FreshContext<S>;
/**
* @deprecated Use {@link RouteHandler} instead.
*/
// deno-lint-ignore no-explicit-any
export type Handlers<T = any, State = Record<string, unknown>> =
HandlerByMethod<T, State>;
export type Handlers<T = any, State = Record<string, unknown>> = RouteHandler<
T,
State
>;
/**
* @deprecated Use {@link HandlerFn} instead.
*/
// deno-lint-ignore no-explicit-any
export type Handler<T = any, State = Record<string, unknown>> = HandlerFn<
T,
State
>;
function defineFn<State>(
fn: (
@@ -40,14 +54,14 @@ function defineFn<State>(
}
/**
* @deprecated Use {@link definePage} instead
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
*/
export const defineApp = defineFn;
/**
* @deprecated Use {@link definePage} instead
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
*/
export const defineRoute = defineFn;
/**
* @deprecated Use {@link definePage} instead
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
*/
export const defineLayout = defineFn;