ts is trying to narrow the type too hard

This commit is contained in:
Chris Wanstrath 2025-10-08 10:01:06 -07:00
parent 78923b3eff
commit 80183653f4

View File

@ -26,9 +26,7 @@ export class VM {
this.scope = new Scope() this.scope = new Scope()
} }
registerFunction(name: string, fn: NativeFunction | Function) { registerFunction(name: string, fn: Function) {
// If it's already a NativeFunction, use it directly
// Otherwise, assume it's a JS function and wrap it
const wrapped = isWrapped(fn) ? fn as NativeFunction : wrapNative(fn) const wrapped = isWrapped(fn) ? fn as NativeFunction : wrapNative(fn)
this.nativeFunctions.set(name, wrapped) this.nativeFunctions.set(name, wrapped)
} }