-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add typings file #32
base: master
Are you sure you want to change the base?
Add typings file #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍥
index.d.ts
Outdated
export interface Program<S, M, V> { | ||
readonly init?: Change<S, M>; | ||
readonly update: Update<M, S>; | ||
readonly view: View<M, S, V>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with generic V
is that for raj/runtime
view
is <State, Message>(state: State, dispatch: Dispatch<Message>): void
as Raj does nothing with the return value. The return value of view is given meaning in the view libraries such as raj-react
. Typing this we either over generalize the core framework or have multiple Program definitions that end-users would need to reconcile.
I'm not saying this is wrong, just something to consider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this only makes sense if we consider raj-react
or similar packages. I've already made typings for raj-react
so I'll make a similar PR to that repo in order to put the generic V
in context for discussing these typings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the typings for raj-react
to put theV
in context are here. Not sure if it is really needed, maybe it could be done somehow without V
.
@jonaskello is there any particular reason why the type-arguments occur in inconsistent order? I'd suggest making them consistent with
I'd also personally prefer names like By the way, Raj made no sense to me until I saw these type-declarations 😉 |
Yes, I agree we should make the order of type params consistent if this would ever get merged. Regarding Btw, I implemented my own version of raj in my project and made a raj-logger as a fork of redux-logger and it is working out quite well. The downside to having no types in raj is that it is hard to make community packages for it like raj-logger since that package would have to import the raj package typings, which are non-existent at this point. If anyone is familiar with the process of gettings types published as |
Just my opinion, but I'm okay with For example, I instantly thought |
@jonaskello did you give up on this? (or did it land somewhere else?) @andrejewski I wish you were more receptive to this. I like the idea of Raj, but I'm basically "on hold" waiting for proper type-definitions - this is likely a roadblock to anyone using TS, since adding correct types for this isn't trivial. Investing in this currently seems too risky for a large-scale project. Just an aside, but many IDEs by now exploit type-declarations well enough to provide better validation, auto-completion and navigation, even in plain JS projects - so this benefits not only TS users. |
This PR is just to support the discussion in #31.