You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
I expect to be able to pass typeof Cat to a function that takes a new(): Cat. I can do that unless Animal has a property, then I can't. I would at the least expect it to work in both cases or in neither case.
Actual behavior:
Errors out with Argument of type 'typeof Cat' is not assignable to parameter of type 'new () => Cat'.
As motivation, this came up in the context of declaring the types of a decorator function. A JS library I'm using decorates classes, returning a new class which makes changes to both the static and instance side of a class type. Something like this:
I had a similar error. The reason was that I didn't set default values for the properties in the constructor, hence the parameterless new(): T won't match.
TypeScript Version: 2.1.4
Code
Expected behavior:
I expect to be able to pass
typeof Cat
to a function that takes anew(): Cat
. I can do that unless Animal has a property, then I can't. I would at the least expect it to work in both cases or in neither case.Actual behavior:
Errors out with
Argument of type 'typeof Cat' is not assignable to parameter of type 'new () => Cat'.
As motivation, this came up in the context of declaring the types of a decorator function. A JS library I'm using decorates classes, returning a new class which makes changes to both the static and instance side of a class type. Something like this:
The text was updated successfully, but these errors were encountered: