Typescript: Implement string extends type

Hey y’all,

A member commented on this lesson video “how would you implement the getItem function?”:

I’m not experienced with typescript but after taking a stab at it, I couldn’t get typescript to stop giving me this error:

Type '<T extends string | number>(id: T) => Book | Tv' is not assignable to type '<T extends string | number>(id: T) => T extends string ? Book : Tv'.
  Type 'Book | Tv' is not assignable to type 'T extends string ? Book : Tv'.
    Type 'Book' is not assignable to type 'T extends string ? Book : Tv'.ts(2322)

Heres the codesandbox I was testing things out in.

Does anyone have any suggestions?