Incorrect application of arguments to external function with default argument?

Hi Folks. probably Yawar =)
Hit a thing today doing bindings for an external function that seemed incorrect to me.

the type signature in ts has a few type [parameters] and shows an optional options argument:

export type UseFormRegister<TFieldValues extends FieldValues> = <
  TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>(
  name: TFieldName,
  options?: RegisterOptions<TFieldValues, TFieldName>,
) => UseFormRegisterReturn;

The function implementation in js provides a default empty object for options:
const register: UseFormRegister = (name, options = {}) => {

my signature in rescript asserts the presence of options to avoid adding runtime code there but allow options.

type useFormRegister<
  'tFieldValues, //extends FieldValues
	'tFieldName, // extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
	'event
> = 
( 
  'tFieldName, // name:
  // options typed as undefined in ts but easy to make an empty options which has 
  // same effect as default options = {} 
  // and saves Undefined.return calls everywhere - AxM
  registerOptions<value, 'event, 'tFieldValues, 'tFieldName>, // options: 
) => useFormRegisterReturn;

This causes my function to be invoked with Curry._2.
Inside of Curry._2 it evaluates register.length and gets 1.

Then calls register with one arg, returning the intended useFormRegisterReturn, and then applying once more with the options which breaks since useFormRegister is not a function.

f.apply is not a function

I have worked around by making register an uncurried function but it seems that no external function is safe from this trouble? Any ideas?

Thanks!
Alex

Hi Alex :slight_smile:

Can you provide a runnable (playground) example? From the description I can’t figure out what’s happening.

Is there a way to force a function to be called through Curry?

yarn start to launch live server, then look at chrome console

This doesn’t have any ReScript code. Can you post an example with ReScript code that triggers the issue?

I couldnt come up with a way to invoke currying in the example, but that would be the generated js.