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

Are Sets supported (using typescript)? #1886

Open
2 tasks done
andrewdang17 opened this issue Mar 17, 2022 · 7 comments · May be fixed by #2088
Open
2 tasks done

Are Sets supported (using typescript)? #1886

andrewdang17 opened this issue Mar 17, 2022 · 7 comments · May be fixed by #2088
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: easy

Comments

@andrewdang17
Copy link

andrewdang17 commented Mar 17, 2022

Question

I'd like to use a Set for one of the model properties but it seems like converting the set to an array and using types.array(types.number) would be my only option. If I try to use it anyways I get an empty array and this typescript error

Type 'Set<number>' is missing the following properties from type 'number[]': length, pop, push, concat, and 24 more.ts(2740)
User.ts(11, 5): The expected type comes from property 'favoritedSongIds' which is declared here on type 'ModelCreationType<ExtractCFromProps<{ id: ISimpleType<number>; accountId: ISimpleType<number>; email: ISimpleType<string>; firstName: ISimpleType<string>; lastName: IMaybeNull<...>; favoritedSongIds: IArrayType<...>; }>>'
@adamkovalsky
Copy link
Contributor

See #381

@coolsoftwaretyler
Copy link
Collaborator

Hey @andrewdang17 and @adamkovalsky! Sorry it took so long for anyone to get to this.

I'm going through and tagging/responding/closing out issues in MobX-State-Tree. Looks like the answer is sets are not supported, but I think we'd be happy to see a PR to that effect.

Much like #381, I'm going to mark this as help/PR accepted. Hopefully someone jumps in if they're looking for a good issue to grab. If not, I imagine a maintainer will try and get this done in the coming months/year.

If either of you is still interested, I'd be happy to get you set up with contributing. If not, no worries.

@coolsoftwaretyler coolsoftwaretyler added help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: easy labels Jun 26, 2023
@singularvoice
Copy link
Contributor

Hey @coolsoftwaretyler
I would be happy to contribute to this issue, Can you tell me what should i do about this issue?

@coolsoftwaretyler
Copy link
Collaborator

Hey @a-hassanzadeh-h - thanks for your interest! I haven't thought too much about it, but here's what I would do to get started:

  1. See if you can replicate this behavior with a custom type. You may find some inspiration in Add types.set #381
  2. Once you have a working implementation, post a CodeSandbox here
  3. We can go over it, explore edge cases, limitations, etc.
  4. Once we feel good about the custom type, we can move on to PR with some tests, documentation, and implementation of a Set type in MST natively.

Let me know what you think! As a heads up, I'm going to be a little busy in the coming weeks. Sorry for any delay in responses.

@chakrihacker
Copy link
Collaborator

Hey @a-hassanzadeh-h have you picked this??

@singularvoice
Copy link
Contributor

Hey, @chakrihacker I was busy in the last few days, But I am working on issue #1939 right now, I can work on this issue in the next week, If anybody else wants take this issue right now, it is okay, they welcome

@chakrihacker
Copy link
Collaborator

I will give it a shot then

@chakrihacker chakrihacker linked a pull request Sep 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants