Skip to content

Commit f041fb9

Browse files
authored
Add proper type annotations for panicProxy (#378)
1 parent 7822151 commit f041fb9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

frontend/src/utilities/panic-proxy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// Import this function and chain it on all `wasm` imports like: const wasm = import("@/../wasm/pkg").then(panicProxy);
44
// This works by proxying every function call wrapping a try-catch block to filter out redundant and confusing `RuntimeError: unreachable` exceptions sent to the console
5-
export function panicProxy(module: any) {
5+
export function panicProxy<T extends object>(module: T): T {
66
const proxyHandler = {
7-
get(target: any, propKey: any, receiver: any) {
7+
get(target: T, propKey: string | symbol, receiver: any): any {
88
const targetValue = Reflect.get(target, propKey, receiver);
99

1010
// Keep the original value being accessed if it isn't a function or it is a class
@@ -28,5 +28,5 @@ export function panicProxy(module: any) {
2828
},
2929
};
3030

31-
return new Proxy(module, proxyHandler);
31+
return new Proxy<T>(module, proxyHandler);
3232
}

0 commit comments

Comments
 (0)