-
Notifications
You must be signed in to change notification settings - Fork 2
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: Refactor ActionWithPayload/ActionWithoutPayload to be uniform #605
Conversation
33b1927
to
7f155a5
Compare
type ActionCreatorWithoutPayload_is_not_assibleable_to_UnknownActionCreatorWithPayload = | ||
AssertFalse< | ||
Has<ActionCreatorWithoutPayload, UnknownActionCreatorWithPayload<unknown>> | ||
>; | ||
|
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.
This test case did not make sense.
// Add letter representations to marble map | ||
for (let i = 'A'.charCodeAt(0); i < 'Z'.charCodeAt(0); i++) { | ||
const letter = String.fromCharCode(i); | ||
marbleMap[letter] = letter; | ||
} | ||
// Add number representations to marble map | ||
for (let i = 0; i < 10; i++) { | ||
// Create marble representations of the 10 first characters | ||
// eg. { A: 'A', B: 'B', ...etc } | ||
const charCodeA = 'A'.charCodeAt(0); | ||
const letter = String.fromCharCode(charCodeA + i); | ||
marbleMap[letter] = letter; | ||
// Create marble representations of the 10 first numbers from 0 | ||
marbleMap[`${i}`] = i; | ||
} |
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.
I had to change these tests because it was using the lengths of the action types.. which obviously changes when you enforce the ActionName
type.
Now the tests are more robust.
type ExtractPayload_extracts_payload2 = AssertTrue< | ||
IsExact<ExtractPayload<ActionCreatorWithPayload>, void> | ||
>; | ||
// type aaa = ExtractPayload<VoidFn>; // weakness of ExtractPayload | ||
// type aaa3 = ExtractPayload<unknown>; // weakness of ExtractPayload |
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.
InferPayloadFromActionCreator is the same as ExtractPayload, although a bit more flexible.
Thinking of renaming the former to the latter, so we use the most flexible version.
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.
I don't know the rxbeach codebase a lot, but this looks fine to me.
@rafaa2 what's wrong with your screenshot? The actionCreator functions have a type attribute, and rxbeach relies on it. |
@sseppola But it should show ActionCreator not the whole object |
The type that appears is a function signature, so it is an action creator. |
@sseppola I am not talking about when you use the action creator, the new object should be displayed when you hover on it as ActionCreator instead of showing its shape: |
They are equivalent. Let's have a call tomorrow |
Co-authored-by: Rafaa <10600830+rafaa2@users.noreply.github.com>
type ExtractPayload_extracts_payload = AssertTrue< | ||
IsExact<ExtractPayload<ActionCreatorWithPayload<Payload>>, Payload> | ||
>; | ||
type ExtractPayload_extracts_payload2 = AssertTrue< |
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.
I love this form of documentation ❤️
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.
Great work 💯
No description provided.