Skip to content

Commit 4aa16a4

Browse files
authored
feat(deno): Use interface for WidgetOptions for better JSR docs (#498)
1 parent eaedc7b commit 4aa16a4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.changeset/brown-jokes-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@anywidget/deno": patch
3+
---
4+
5+
Prefer interface over type for WidgetOptions

packages/deno/deno.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
"@std/testing": "jsr:@std/testing@0.220.1",
3030
"unzipit": "npm:unzipit@1.4",
3131
"zod": "npm:zod@3.9"
32+
},
33+
"publish": {
34+
"exclude": ["npm.README.md"]
3235
}
3336
}

packages/deno/src/mod.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,22 @@ function to_esm<State>({
222222
return `${imports}\nexport default { render: ${render.toString()} }`;
223223
}
224224

225+
type Awaitable<T> = T | Promise<T>;
226+
225227
/** The options bag to pass to the {@link widget} method. */
226-
export type WidgetOptions<State> = {
228+
export interface WidgetOptions<State> {
227229
/** The initial widget state. */
228230
state: State;
229231
/** A function that renders the widget. This function is serialized and sent to the front end. */
230232
render: (context: {
231233
model: FrontEndModel<State>;
232234
el: HTMLElement;
233-
}) => unknown;
235+
}) => Awaitable<(() => Awaitable<void>) | undefined>;
234236
/** The imports required for the front-end function. */
235237
imports?: string;
236238
/** The version of the anywidget front end to use. */
237239
version?: string;
238-
};
240+
}
239241

240242
/**
241243
* Creates an anywidget for the Deno Jupyter kernel.

0 commit comments

Comments
 (0)