chore: Refactor stateful component check in constructState#3251
chore: Refactor stateful component check in constructState#3251GuillaumeRx merged 3 commits intomainfrom
constructState#3251Conversation
constructStateconstructState
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3251 +/- ##
==========================================
- Coverage 94.98% 94.98% -0.01%
==========================================
Files 511 511
Lines 11314 11300 -14
Branches 1754 1737 -17
==========================================
- Hits 10747 10733 -14
Misses 567 567 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| */ | ||
| export function isStatefulComponent(component: { type: string }): component is { | ||
| type: StatefulComponentType; | ||
| props: Record<string, any>; |
There was a problem hiding this comment.
This is not ideal 🤔 Is this required?
There was a problem hiding this comment.
Can we at least type it to be a union of the stateful component's props?
There was a problem hiding this comment.
Thought it was required at some point but it isn't anymore apparently, removed
| * @returns Whether the component is a stateful component. | ||
| */ | ||
| export function isStatefulComponent(component: { type: string }): component is { | ||
| type: StatefulComponentType; |
There was a problem hiding this comment.
Oh, does this then properly infer the props inside the if-clause in constructState? 🤔
There was a problem hiding this comment.
Yes, I have no issues in my IDE and when I look at the infered type its an union of the stateful components, I would like to send you a screenshot but I can't hit ctrl without the IDE context widow closing 😅
This PR refactors
constructStateto use an util function calledisStatefulComponentthat uses an array of component types that includes all the stateful components.Fixes: #3235