Consider the following code:

```
interface Foo<T1> {
  foo: string;
  baz: T1;
}

function toFoo<T2>(value: T2): Foo<T2> {
  return {
    foo: 'bar',
    baz: value
  };
}

// Actually this function is imported from an NPM package so I can't change it
// The example is given for a better illustration
function memoize<T3, T4>(func: (arg: T3) => T4): (arg: T3) => T4 {
  // Some implementation...
  return func;
}

const memoizedToFoo: {<T5>(value: T5): Foo<T5>} = // ???

```

The `toFoo` function is a generic. I need to make a memoized version of `toFoo` that is a generic too. I can't change the `memoize` type and implementation. How to implement `memoizedToFoo` so that it matches the given interface?

I try this, but it doesn't work:

```
const memoizedToFoo<T5> = memoize(toFoo<T5>); // unexpected <T5>

```