Skip to content

Commit db45841

Browse files
committed
improve types around __next_app__
1 parent 5f455e1 commit db45841

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

packages/next/src/build/templates/app-page.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export { tree, pages }
2121
export { default as GlobalError } from 'VAR_MODULE_GLOBAL_ERROR' with { 'turbopack-transition': 'next-server-utility' }
2222

2323
// These are injected by the loader afterwards.
24-
declare const __next_app_require__: any
25-
declare const __next_app_load_chunk__: any
24+
declare const __next_app_require__: (id: string | number) => unknown
25+
declare const __next_app_load_chunk__: (id: string | number) => Promise<unknown>
2626

2727
// INJECT:__next_app_require__
2828
// INJECT:__next_app_load_chunk__

packages/next/src/server/app-render/app-render.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,9 @@ async function renderToHTMLOrFlightImpl(
11171117
// to treat chunk loading with similar semantics as cache reads to avoid
11181118
// async loading chunks from causing a prerender to abort too early.
11191119
// @ts-ignore
1120-
globalThis.__next_chunk_load__ = (...args: Array<any>) => {
1120+
globalThis.__next_chunk_load__ = (
1121+
...args: Parameters<typeof instrumented.loadChunk>
1122+
) => {
11211123
const loadingChunk = instrumented.loadChunk(...args)
11221124
trackChunkLoading(loadingChunk)
11231125
return loadingChunk

packages/next/src/server/client-component-renderer-logger.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import type { AppPageModule } from './route-modules/app-page/module'
2+
13
// Combined load times for loading client components
24
let clientComponentLoadStart = 0
35
let clientComponentLoadTimes = 0
46
let clientComponentLoadCount = 0
57

6-
export function wrapClientComponentLoader(ComponentMod: any) {
8+
export function wrapClientComponentLoader(
9+
ComponentMod: AppPageModule
10+
): AppPageModule['__next_app__'] {
711
if (!('performance' in globalThis)) {
812
return ComponentMod.__next_app__
913
}
1014

1115
return {
12-
require: (...args: any[]) => {
16+
require: (...args) => {
1317
const startTime = performance.now()
1418

1519
if (clientComponentLoadStart === 0) {
@@ -23,7 +27,7 @@ export function wrapClientComponentLoader(ComponentMod: any) {
2327
clientComponentLoadTimes += performance.now() - startTime
2428
}
2529
},
26-
loadChunk: (...args: any[]) => {
30+
loadChunk: (...args) => {
2731
const startTime = performance.now()
2832
try {
2933
return ComponentMod.__next_app__.loadChunk(...args)

0 commit comments

Comments
 (0)