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
MyComponent.tsx(19,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
Type 'ComponentClass<Pick<any, never>> & { WrappedComponent: ComponentType<any>; }' is not assignable to type 'typeof MyComponent'.
Type 'Component<Pick<any, never>, ComponentState>' is not assignable to type 'MyComponent'.
Types of property 'render' are incompatible.
Type '() => false | Element' is not assignable to type '() => Element'.
Type 'false | Element' is not assignable to type 'Element'.
Type 'false' is not assignable to type 'Element'.
However, when used like this, TypeScript compiles it fine:
See #4881. TypeScript decorators are severely limited at the moment; a function can't be used as a decorator if it changes the type of the thing it's decorating.
A decorator can change the type as long as it is assignable to the original declaration.
In this case render return type is inferred to be Element and not false | Element. The root cause of this issue really is #1373. The usual expectation is that render will inherit the return type of its base class, and not override it, but that is not the case(#1373 has more details).
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
This is related to react-redux types give errors when used as decorators
TypeScript Version: 2.5.3
Code
Expected behavior:
Should compile properly
Actual behavior:
Results in error:
However, when used like this, TypeScript compiles it fine:
Why is type-checking different in both cases, when it should be the same?
The text was updated successfully, but these errors were encountered: