This snippet

```
function problem<T>(callback: T | (() => T)) : T {
    return typeof callback === 'function' ? callback() : callback;
}

```

produces the error

```
This expression is not callable.
  Not all constituents of type '(() => T) | (T & Function)' are callable.
    Type 'T & Function' has no call signatures. ts(2349)

```

It took me a while to understand that `Function` itself indeed doesn't mean much, since I need is a *parameter-less* function.

In special cases like `T = number`, I can simple switch to testing `typeof callback === 'number'` and be done. However, I need a general solution.

I'd like to

* either restrict `T` so that it does not include functions, which (as I hope) solves the problem.
* or do a runtime test for parameterless function

I'm also open for alternatives (my main point is to learn about the details).

What are the possibilities?

### Problem explanation

With `function myfun(s: string) {return s;}` and the call

```
problem(myfun);

```

the type `T = (s: string) => string` gets correctly inferred. There should be no callback call like `myfun()`; instead, `myfun` should be returned. However, it goes wrong as `typeof callback === 'function'` holds.

### Update

I was wrong assuming that Checking `callback instanceof Function` is AFAIK exactly the same.

It's different, as the [playground from the answer](https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=10&pc=1#code/GYVwdgxgLglg9mABABwE5wEYBsCmBbAHgBUA+ACggEMssNKIBrALkSMQB9EyyBKRAXhKsePFmwDeAKESJUOKCFRIqNOo0QwwAZyiVIOOMEQAxcNHhIA-IhW16DXoha21DANySAvpMkQEOm2o7RgAleUVtAGUoVE0AcwEuPkFEAHIACRwaOAAaRAB1OFQsABNEYHQ8crNYBABCVI8-bShEACsQHQBBaNiwBP40zOy8wuKyirgq5p09KAafGbhcADosODiyNExcPAog1zCFJS1e+JEm-2WcNY2t9Gx8Mg7us-6LySA) shows. However, adding

```
const myfun = (s: string) => s;
console.log(problem(myfun));

```

makes it say

```
Argument of type '(s: string) => string' is not assignable to parameter of type 'string | (() => string)'.
  Type '(s: string) => string' is not assignable to type '() => string'.ts(2345)
doAfter.ts(57, 21): Did you mean to call this expression?

```

This sounds like a bug as this line

```
console.log(problem<(s: string) => string>(myfun));

```

compiles and there's no type ambiguity. However, it doesn't work, `undefined` gets returned instead of `myfun` itself.

### The potential duplicate

The answer of the linked question doesn't solve my problem either:

* Plain `correct(myfun);` does not compile.
* Valid `correct<(s: string) => string>(myfun)` return undefined.

My second question "(how to) do a runtime test for parameterless function" is absent from the potential duplicate, too.