Any way to annotate a type that base on argument function return type

I am doing a project that compare TypeScript to ReScript here. One of the code need this type

@module("zustand") external create: ((set, get) => noteState) => (noteState => 'a) => 'a = "default"

The problem is I cannot use annotation in create function and I wish to have identical working code with TypeScript project.

ReScript won’t let me do this. I can think the workaround now by using variant but I still want to find another way.

Edit: I wish to do this because it’s how Zustand is suppose to work.

@pontakornth You can do like below

type returnedFn<'a> = noteState => 'a
@module("zustand") external create: ((set, get) => noteState, returnedFn<'a>) => 'a = "default"

Thank you. I actually give up using Zustand because it’s too tedious. It’s not suitable for ReScript anyway. I might try to test this solution some time.