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
Currently I'm trying to rewrite themr in TS to provide consistent up-to-date typings and I'm in the middle of the struggle started in #39
The problem is that switching from correct React.ComponentClass<P> to component constructor type (with new()) is completely broken with strictNullChecks on, here's my comment
@themr('foo')//error - Type 'null' is not assignable to type 'Element'classFooClassextendsReact.Component<any,any>{render()/*: JSX.Element | null //ok when uncommented*/{return<div>hi</div>;}}
Moreover, decorating a class with @themr complains on every lifecycle method (like componentWillMount) of decorated class as TS can't cast it to ComponentClass. On the other hand, calling themr as a function on existing class works fine - seems like decorators are broken in TS.
Well, at least they are still behind experimental flag.
@mpodlasin@odensc Could you please check if you do use decorators instead of composing HOCs separately from actual component class or sfc which is more natural for react ecosystem in general especially when using recompose?
If it's ok for you and if it's worth dropping experimental decorators, I would open a PR with a fresh new themr fully in typescript.
The good news are that now I'm finally able to overwrite props in decorated component with their non-necessary versions, thanks to this comment
So that themed component does not require theme object to be passed via props but still checks its type if it is present.
UPDATE: still it will be possible and absolutely transparent to use themr as decorator for current ES6 users.
The text was updated successfully, but these errors were encountered:
raveclassic
changed the title
Possible drop of support of using themr as decorator
Possible drop of support of using themr as decorator with TypeScript
Jun 28, 2017
Currently I'm trying to rewrite
themr
in TS to provide consistent up-to-date typings and I'm in the middle of the struggle started in #39The problem is that switching from correct
React.ComponentClass<P>
to component constructor type (withnew()
) is completely broken withstrictNullChecks
on, here's my commentMoreover, decorating a class with
@themr
complains on every lifecycle method (likecomponentWillMount
) of decorated class as TS can't cast it toComponentClass
. On the other hand, callingthemr
as a function on existing class works fine - seems like decorators are broken in TS.Well, at least they are still behind experimental flag.
@mpodlasin @odensc Could you please check if you do use decorators instead of composing HOCs separately from actual component class or sfc which is more natural for react ecosystem in general especially when using recompose?
If it's ok for you and if it's worth dropping experimental decorators, I would open a PR with a fresh new
themr
fully in typescript.The good news are that now I'm finally able to overwrite props in decorated component with their non-necessary versions, thanks to this comment
So that themed component does not require theme object to be passed via props but still checks its type if it is present.
UPDATE: still it will be possible and absolutely transparent to use themr as decorator for current ES6 users.
The text was updated successfully, but these errors were encountered: