#How do I check whether a variable is a class constructor or a function?

1 messages · Page 1 of 1 (latest)

river osprey
#

If I have a variable like this:

const myVar: typeof myClass | (() => string);

How do I check programmatically which it is so I can do either new myVar() if it's a class or myVar() if it's the function?

ivory compass
#

I would suggest changing myVar, depending on how you want to use it later.

river osprey
#

I see, thank you