Linked Questions

Popular Questions

Explicitly, is it possible to create a generic type IsGenericFunction<T> so that

  • IsGenericFunction<<T>(a: T) => T> resolves to true
  • IsGenericFunction<<T,U>(a: T, b: U) => unknown> resolves to true (etc.)
  • IsGenericFunction<(a: number) => string> resolves to false (etc. etc.)
  • IsGenericFunction<X> resolves to false for any non-function type X


My apologies if this is a duplicate, I tried hard to search but there are so many Q&As that boil down to can I figure out the type a generic function was called with (usually at runtime) that I couldn't figure out how to sort through and find out if this more or less unrelated question had been raised and answered.

I can test for being a function type via T extends (...args: any) => any but both generic and non-generic function types pass that test. How can I differentiate between the two, if possible?

Related Questions