it must be an easy one but I can't figure out why typescript throws an error.
taking this question and tweaking at a little bit:
type Fruit = "Orange" | "Apple" | "Banana";
const myFruit: Fruit = "Apple";
const myString: string = myFruit; //accepted!
// now with functions
type fruitFunc = (key: Fruit) => void;
type stringFunc = (key: string) => void;
const myFruitFunc: fruitFunc = (key: Fruit) => {};
const myStringFunc: stringFunc = myFruitFunc; //Error!
// Type 'fruitFunc' is not assignable to type 'stringFunc'.
// Types of parameters 'key' and 'key' are incompatible.
// Type 'string' is not assignable to type 'Fruit'.ts(2322)
Why is that happening? I'm not trying to assign a string to fruit, but the opposite...