NodeGroup Add generic type from incoming data #69
Open
FranzFlueckiger wants to merge 2 commits intosghall:masterfrom
Open
NodeGroup Add generic type from incoming data #69FranzFlueckiger wants to merge 2 commits intosghall:masterfrom
FranzFlueckiger wants to merge 2 commits intosghall:masterfrom
Conversation
added 2 commits
March 27, 2021 22:39
This PR allows typescript users to directly have the type of the incoming data array inferred in all the following functions: keyAccessor, start, enter, update and leave. If this PR is accepted, nothing will change from the user's perspective except that they will enjoy code completion where they might expect it to be.
Owner
|
Good point 👍 Keep thinking I'm just going to re-write this in TS. I think you need to make it optional, right? So not all TS users need to provide a type? Like... type SomeType<T = void> = OtherType<T>; |
Author
|
Hi Steve, sorry for the late response. You're right that the generic should be optional so that this change is non-breaking for the users. |
haydn
reviewed
Aug 18, 2021
| enter?: (data: T, index: number) => HashMap | Array<HashMap> | ||
| update?: (data: T, index: number) => HashMap | Array<HashMap> | ||
| leave?: (data: T, index: number) => HashMap | Array<HashMap> | ||
| children: (nodes: Array<any>) => React.ReactElement<any> |
There was a problem hiding this comment.
I feel like it's just as important to tighten-up the any type here too. I've got this type in my codebase:
type ReactMoveNode<Data, State> = {
key: string;
data: Data;
state: State;
};That I'm using like this:
<NodeGroup
// ...etc
>
{(
nodes: Array<ReactMoveNode<{ id: string }, { top: number; opacity: number }>>
) => (
// ...etc
)}
</NodeGroup>It should be possible to wrap all that up together here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR allows typescript users to directly have the type of the incoming data array inferred in all the following functions:
keyAccessor, start, enter, update and leave.
If this PR is accepted, nothing will change from the user's perspective except that they will enjoy code completion where they might expect it to be.