1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
1
import { match } from "path-to-regexp" ;
4
2
import type { HTTPMethod } from "./routes" ;
5
3
6
4
/* TODO: Grab these from @cloudflare/workers-types instead */
7
- type Params < P extends string = any > = Record < P , string | string [ ] > ;
5
+ type Params < P extends string = string > = Record < P , string | string [ ] > ;
8
6
9
7
type EventContext < Env , P extends string , Data > = {
10
8
request : Request ;
11
- waitUntil : ( promise : Promise < any > ) => void ;
9
+ waitUntil : ( promise : Promise < unknown > ) => void ;
12
10
next : ( input ?: Request | string , init ?: RequestInit ) => Promise < Response > ;
13
11
env : Env & { ASSETS : { fetch : typeof fetch } } ;
14
12
params : Params < P > ;
@@ -17,7 +15,7 @@ type EventContext<Env, P extends string, Data> = {
17
15
18
16
declare type PagesFunction <
19
17
Env = unknown ,
20
- P extends string = any ,
18
+ P extends string = string ,
21
19
Data extends Record < string , unknown > = Record < string , unknown >
22
20
> = ( context : EventContext < Env , P , Data > ) => Response | Promise < Response > ;
23
21
/* end @cloudflare/workers-types */
@@ -34,12 +32,12 @@ declare const routes: RouteHandler[];
34
32
35
33
// expect an ASSETS fetcher binding pointing to the asset-server stage
36
34
type Env = {
37
- [ name : string ] : any ;
35
+ [ name : string ] : unknown ;
38
36
ASSETS : { fetch ( url : string , init : RequestInit ) : Promise < Response > } ;
39
37
} ;
40
38
41
39
type WorkerContext = {
42
- waitUntil : ( promise : Promise < any > ) => void ;
40
+ waitUntil : ( promise : Promise < unknown > ) => void ;
43
41
} ;
44
42
45
43
function * executeRequest ( request : Request , env : Env ) {
@@ -107,7 +105,11 @@ export default {
107
105
const { value } = handlerIterator . next ( ) ;
108
106
if ( value ) {
109
107
const { handler, params } = value ;
110
- const context : EventContext < unknown , any , any > = {
108
+ const context : EventContext <
109
+ unknown ,
110
+ string ,
111
+ Record < string , unknown >
112
+ > = {
111
113
request : new Request ( request . clone ( ) ) ,
112
114
next,
113
115
params,
0 commit comments