Skip to content

Commit 86a532e

Browse files
BridgeJS: Add helper SetupOptionsFn type to test.d.ts
1 parent 3b305b7 commit 86a532e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Plugins/PackageToJS/Templates/test.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { InstantiateOptions, instantiate } from "./instantiate";
22

3+
export type SetupOptionsFn = (
4+
options: InstantiateOptions,
5+
context: {
6+
isMainThread: boolean,
7+
}
8+
) => Promise<InstantiateOptions>
9+
310
export function testBrowser(
411
options: {
512
preludeScript?: string,

Plugins/PackageToJS/Templates/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export async function testBrowserInPage(options, processInfo) {
157157
});
158158

159159
const { instantiate } = await import("./instantiate.js");
160+
/** @type {import('./test.d.ts').SetupOptionsFn} */
160161
let setupOptions = (options, _) => { return options };
161162
if (processInfo.preludeScript) {
162163
const prelude = await import(processInfo.preludeScript);

Tests/prelude.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/** @type {import('../.build/plugins/PackageToJS/outputs/PackageTests/test.d.ts').SetupOptions} */
2-
export function setupOptions(options, context) {
1+
// @ts-check
2+
3+
/** @type {import('../.build/plugins/PackageToJS/outputs/PackageTests/test.d.ts').SetupOptionsFn} */
4+
export async function setupOptions(options, context) {
35
Error.stackTraceLimit = 100;
46
setupTestGlobals(globalThis);
57
return {

0 commit comments

Comments
 (0)