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

Commit

Permalink
Manually update index.d.ts with the Pages Plugins types
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble committed Apr 22, 2022
1 parent 3e4eed0 commit 3a91019
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-moles-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-types": patch
---

feature: Adds the `PagesPluginFunction` type and internal `functionPath` to Functions' context.
20 changes: 20 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1959,3 +1959,23 @@ declare type PagesFunction<
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>
> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;

type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
request: Request;
functionPath: string;
waitUntil: (promise: Promise<any>) => void;
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
env: Env & { ASSETS: { fetch: typeof fetch } };
params: Params<P>;
data: Data;
pluginArgs: PluginArgs;
};

declare type PagesPluginFunction<
Env = unknown,
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>,
PluginArgs = unknown
> = (
context: EventPluginContext<Env, Params, Data, PluginArgs>
) => Response | Promise<Response>;

0 comments on commit 3a91019

Please sign in to comment.