Skip to content

Commit c53d36e

Browse files
committed
improve typing
1 parent 7da13fe commit c53d36e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/open-next/src/build/copyTracedFiles.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ interface CopyTracedFilesOptions {
5858
skipServerFiles?: boolean;
5959
}
6060

61-
// TODO: add all the necessary manifests here
62-
function getManifests(nextDir: string) {
61+
export function getManifests(nextDir: string) {
6362
return {
6463
buildId: loadBuildId(nextDir),
6564
config: loadConfig(nextDir),

packages/open-next/src/build/patch/codePatcher.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from "node:fs/promises";
22
import logger from "../../logger.js";
33
import * as buildHelper from "../helper.js";
4+
import type { getManifests } from "../copyTracedFiles.js";
45

56
// Either before or after should be provided, otherwise just use the field directly
67
export interface VersionedField<T> {
@@ -21,14 +22,22 @@ export interface VersionedField<T> {
2122
}
2223

2324
export type PatchCodeFn = (args: {
24-
// The content of the file that needs to be patched
25+
/**
26+
* The code of the file that needs to be patched
27+
*/
2528
code: string;
26-
// The final path of the file that needs to be patched
29+
/**
30+
* The final path of the file that needs to be patched
31+
*/
2732
filePath: string;
28-
// All js files that will be included in this specific server function
33+
/**
34+
* All files that are traced and will be included in the bundle
35+
*/
2936
tracedFiles: string[];
30-
// All next.js manifest that are present at runtime - Key relative to `.next` folder
31-
manifests: Record<string, any>;
37+
/**
38+
* Next.js manifests that are used by Next at runtime
39+
*/
40+
manifests: ReturnType<typeof getManifests>;
3241
}) => Promise<string>;
3342

3443
export interface CodePatcher {
@@ -69,7 +78,7 @@ export function extractVersionedField<T>(
6978
export async function applyCodePatches(
7079
buildOptions: buildHelper.BuildOptions,
7180
tracedFiles: string[],
72-
manifests: Record<string, any>,
81+
manifests: ReturnType<typeof getManifests>,
7382
codePatcher: CodePatcher[],
7483
) {
7584
const nextVersion = buildOptions.nextVersion;

0 commit comments

Comments
 (0)