-
Notifications
You must be signed in to change notification settings - Fork 10
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
SetOf(type) and other collection checkers #12
Comments
I do eventually want to support custom types. For now, I will probably just add SetOf, MapOf. I will think on the API for a custom type checker afterwards. I could just expose |
I think this will get us by. const ImmutableMap = KeyedCollection(Immutable.Map, map => map.toObject());
const ImmutableListOf = TypedCollection(Immutable.List, list => list.toArray());
class T {
@param(ImmutableMap({key: String, val: String}))
doThing() {
}
@param(ImmutableListOf(Number))
doOtherThing() {
}
}
@callumlocke any comments? |
looks great |
What about
SetOf(type)
, likeArrayOf
but for ES6 sets?Maybe also
MapOf(keyType, valueType)
?This also got me thinking about extensibility... for example, if I am using an a custom/library-provided collection type like
Immutable.OrderedSet
, is there some way I could define my ownImmutableOrderedSetOf(type)
(which I could then compose with other built-ins likeOptional
orArrayOf()
, etc)?Maybe extensibility could be provided with a 'custom' type checker, which lets you supply a callback to examine the value in a custom way, like this:
(I don't actually know if this would work, just an idea.)
The text was updated successfully, but these errors were encountered: