Identity Functions 5 exercises
Problem

# Add Constraints to an Identity Functionself.__wrap_balancer=(t,e,n)=>{n=n||document.querySelector(`[data-br="\${t}"]`);let o=n.parentElement,r=E=>n.style.maxWidth=E+"px";n.style.maxWidth="";let i=o.clientWidth,s=o.clientHeight,c=i/2,u=i,d;if(i){for(;c+1<u;)d=~~((c+u)/2),r(d),o.clientHeight==s?u=d:c=d;r(u*e+i*(1-e))}};self.__wrap_balancer(":Rhd9r6:",1)

Let's continue with the `fruits` example.

Here we have a `narrowFruits` function that looks a lot like the the `asConst` function from the previous exercise:

``````export const narrowFruits = <TFruits>(t: TFruits) => t;
``````

However this time we want to narrow the type to only work with a

## Transcript

0:00 In this exercise, we have a similar kind of function that we had before, where we want to capture the name and price of these fruits, but we also want to make sure that nothing else can be passed in here.

0:13 You shouldn't be able to pass in an array of strings, shouldn't be able to pass in strings, shouldn't be able to pass in anything except something that's constrained to name, "apple," price 1, and an array of those, of course.

0:24 We still want to capture the same type of data as in the previous exercise, but we want it to be constrained. There's an interesting little challenge here for you, and there's a couple of little gotchas here.

0:35 I'm not going to tell you what those are. I think you might know the basics. You know how to constrain a type annotation, and you know how to make something const. I'll leave you to figure out the rest. Good luck.