Act differentely according to a given type in a generic function

Viewed 18
type Foo = number | string

function f<Type extends Foo>(v: Type[]) {
  // can I act here in function of Type?
  // pseudo-code: if (Type == number) {} else if (Type == string) {}
}

f<number>([1, 2]);

I'm a typescript beginner so this question is probably very naive

0 Answers
Related