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

[FEAT-REQ] Custom ID type for TreeNode #42

Open
GamerGirlandCo opened this issue May 21, 2024 · 1 comment
Open

[FEAT-REQ] Custom ID type for TreeNode #42

GamerGirlandCo opened this issue May 21, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@GamerGirlandCo
Copy link

Is your feature request related to a problem? Please describe.
I tried changing an existing data type in my project to extend TreeNode. However, since the ID is assumed to be a string, typescript complains.

Describe the solution you'd like
Change the TreeNode interface to be generic

export interface TreeNode<T> {
  id: T,
  // ...
}

Describe alternatives you've considered
N/A

Screenshots or screen records
N/A

Additional context
N/A

Would you like to work on this feature?
Absolutely!

@GamerGirlandCo GamerGirlandCo added the enhancement New feature or request label May 21, 2024
@JairajJangle
Copy link
Owner

JairajJangle commented May 23, 2024

@GamerGirlandCo Hey there! 👋

Thanks for your feature request and your interest in contributing to the project!

For IDs, I'd suggest using string | number types instead of a more generic template type. These are the most common and practical types for IDs. If you have a specific use case that requires other types, please let me know so we can consider any potential challenges.

So, the TreeNode would look like this:

export interface TreeNode<T extends (string| number)> {
    id: T;
    name: string;
    children?: TreeNode<T>[];
    [key: string]: any;
}

If you'd like to work on this feature and make a PR for it, please ensure all test cases pass and that necessary refactorizations are in place.

Feel free to reach out if you have any questions. Your contribution is much appreciated!

@JairajJangle JairajJangle added the help wanted Extra attention is needed label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants