Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeGroup Add generic type from incoming data #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/NodeGroup/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import * as React from "react";
import * as React from "react"
import { HashMap, GetInterpolator } from '..'

export interface INodeGroupProps {
data: Array<any>;
keyAccessor: (data: any, index: number) => string | number;
interpolation?: GetInterpolator;
start: (data: any, index: number) => HashMap;
enter?: (data: any, index: number) => (HashMap | Array<HashMap>);
update?: (data: any, index: number) => (HashMap | Array<HashMap>);
leave?: (data: any, index: number) => (HashMap | Array<HashMap>);
children: (nodes: Array<any>) => React.ReactElement<any>;
export interface INodeGroupProps<T> {
data: Array<T>
keyAccessor: (data: T, index: number) => string | number
interpolation?: GetInterpolator
start: (data: T, index: number) => HashMap
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>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}

export declare class INodeGroup extends React.Component<INodeGroupProps> { }
export declare class INodeGroup<T> extends React.Component<
INodeGroupProps<T>
> {}

export default INodeGroup
export default INodeGroup