[core] fix(PanelStack2): improve types for common use cases #4570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4272 again, in a better way, building on #4541
Checklist
Changes proposed in this pull request:
#4541 wasn't a very good change because it constrained
PanelStack2
to only working with homogenous panels in a panel stack. The docs example was very simple and did not reflect typical panel stack usage where there are usually heterogenous panels with different info and actions on each one. This PR updates the docs example to this kind of heterogenous use case.It also adds a second generic type param which allows us to fix #4272 while being explicit (more type safe) about which kinds of panel interfaces are allowed in a particular panel stack.The generic type param for
PanelStack2Props
andPanelStack2
has been changed to one that represents aPanel<P>
object. When this genericT
is specified (or inferred) as the type union of all possible panels in the stack, we get accurate types foronOpen
andonClose
, fixing #4272.Reviewers should focus on:
Check out the new API in use in docs-app, check out the updated documentation, JSDoc comments...