JS: fix FFI "wrapper" and "dynamic"
Fix JavaScript support for "wrapper" and "dynamic" foreign imports.
Part of this was fixed in this ghcjs commit but wasn't ported in the JS backend.
This fixes at least test ffi011
which was marked as broken on #22363 (but the ticket description is misleading for this case).