Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit a016b11

Browse files
authored
Manually update index.d.ts with the Pages Plugins types (#224)
1 parent 3e4eed0 commit a016b11

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.changeset/six-moles-argue.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/workers-types": patch
3+
---
4+
5+
feature: Adds the `PagesPluginFunction` type and internal `functionPath` to Functions' context.

index.d.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1959,3 +1959,23 @@ declare type PagesFunction<
19591959
Params extends string = any,
19601960
Data extends Record<string, unknown> = Record<string, unknown>
19611961
> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
1962+
1963+
type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
1964+
request: Request;
1965+
functionPath: string;
1966+
waitUntil: (promise: Promise<any>) => void;
1967+
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
1968+
env: Env & { ASSETS: { fetch: typeof fetch } };
1969+
params: Params<P>;
1970+
data: Data;
1971+
pluginArgs: PluginArgs;
1972+
};
1973+
1974+
declare type PagesPluginFunction<
1975+
Env = unknown,
1976+
Params extends string = any,
1977+
Data extends Record<string, unknown> = Record<string, unknown>,
1978+
PluginArgs = unknown
1979+
> = (
1980+
context: EventPluginContext<Env, Params, Data, PluginArgs>
1981+
) => Response | Promise<Response>;

0 commit comments

Comments
 (0)