File tree 3 files changed +7
-18
lines changed
packages/next/src/server/lib
test/development/app-dir/dev-fetch-hmr/app 3 files changed +7
-18
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,7 @@ type PatchedFetcher = Fetcher & {
33
33
export const NEXT_PATCH_SYMBOL = Symbol . for ( 'next-patch' )
34
34
35
35
function isFetchPatched ( ) {
36
- // @ts -ignore
37
- return globalThis [ NEXT_PATCH_SYMBOL ] === true
36
+ return ( globalThis as Record < symbol , unknown > ) [ NEXT_PATCH_SYMBOL ] === true
38
37
}
39
38
40
39
export function validateRevalidate (
@@ -801,8 +800,7 @@ function createPatchedFetcher(
801
800
patched . __nextPatched = true as const
802
801
patched . __nextGetStaticStore = ( ) => staticGenerationAsyncStorage
803
802
patched . _nextOriginalFetch = originFetch
804
- // @ts -ignore
805
- globalThis [ NEXT_PATCH_SYMBOL ] = true
803
+ ; ( globalThis as Record < symbol , unknown > ) [ NEXT_PATCH_SYMBOL ] = true
806
804
807
805
return patched
808
806
}
Original file line number Diff line number Diff line change @@ -127,9 +127,8 @@ export async function initialize(opts: {
127
127
require ( './router-utils/setup-dev-bundler' ) as typeof import ( './router-utils/setup-dev-bundler' )
128
128
129
129
const resetFetch = ( ) => {
130
- global . fetch = originalFetch
131
- // @ts -ignore
132
- global [ NEXT_PATCH_SYMBOL ] = false
130
+ globalThis . fetch = originalFetch
131
+ ; ( globalThis as Record < symbol , unknown > ) [ NEXT_PATCH_SYMBOL ] = false
133
132
}
134
133
135
134
const setupDevBundlerSpan = opts . startServerSpan
Original file line number Diff line number Diff line change @@ -4,25 +4,17 @@ import { ReactNode } from 'react'
4
4
const magicNumber = Math . random ( )
5
5
const originalFetch = globalThis . fetch
6
6
7
- console . log ( 'monkey patching fetch' )
8
-
9
- // @ts -ignore
10
7
globalThis . fetch = async (
11
8
resource : URL | RequestInfo ,
12
9
options ?: RequestInit
13
10
) => {
14
- let url : string
15
- if ( typeof resource === 'string' ) {
16
- url = resource
17
- } else {
18
- url = resource instanceof URL ? resource . href : resource . url
19
- }
11
+ const request = new Request ( resource )
20
12
21
- if ( url === 'http://fake.url/secret' ) {
13
+ if ( request . url === 'http://fake.url/secret' ) {
22
14
return new Response ( 'monkey patching is fun' )
23
15
}
24
16
25
- if ( url === 'http://fake.url/magic-number' ) {
17
+ if ( request . url === 'http://fake.url/magic-number' ) {
26
18
return new Response ( magicNumber . toString ( ) )
27
19
}
28
20
You can’t perform that action at this time.
0 commit comments