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

Utilise tuples to fix function types #82

Closed
wants to merge 3 commits into from
Closed

Utilise tuples to fix function types #82

wants to merge 3 commits into from

Conversation

Carl-Foster
Copy link
Contributor

@Carl-Foster Carl-Foster commented Sep 27, 2018

I set this up to see if I could use tuple types to fix some of the lingering issues. I think this has fixed it although I'm not 100% sure.

I think this fixes #44 and #63 but does require a bump in TypeScript version

@Carl-Foster
Copy link
Contributor Author

@piotrwitek Any thoughts on this?

@openscript
Copy link

This works for me. Thank you @Carl-Foster.

@twavv
Copy link

twavv commented Nov 28, 2018

@piotrwitek Don't mean to bother, but any update on this?

Currently my best workaround is

type MyActionUnion = ActionType<typeof actionOne> | ActionType<typeof actionOne>;
const isMyActionUnion = (action: Action): action is MyActionUnion => {
  return isActionOf(actionOne, action) || isActionOf(actionTwo, action);
};

// In epic
action$.pipe(
    filter(isMyActionUnion),
    // ...
);

@piotrwitek
Copy link
Owner

piotrwitek commented Nov 28, 2018

For the moment this is blocked, first I need to finish rewrite of type-testing suite to dts-jest because the utility we're using right now is really poor (written by me like a year ago when type-testing wasn't really a thing yet!).

I already rewritten my other library utility-types and it's super cool. Should be ready in a few days, then I can come back here.

EDIT: Maybe I can do it tomorrow if I stay super motivated

@Carl-Foster
Copy link
Contributor Author

@piotrwitek do you want me to update this in some way?

@piotrwitek
Copy link
Owner

Thanks for a quick response @Carl-Foster, there'll be quite a lot :) So please wait a bit more as for the moment I cannot predict exactly what I'll end up with. I'll see tomorrow.

@piotrwitek
Copy link
Owner

Hey, after the analysis the only useful part here is the simplification of overloads in is-action-of.ts file. Strict Function types were fixed on typesafe-actions@2.x.x release line that is still working with previous TS v2.9. This change however require recent TS v3.0 which can be shipped on recently upgraded 3.x.x release line.

The simplification using tuples looks good from code maintenance perspective and shouldn't change any behaviour of the library type-wise. We need to rebase it and discard all other changes except is-action-of.ts file refactoring.

I have just added new type tests cases with type-tests snapshots using new test suite just to be sure that all previous use-cases are still covered and it is not breaking anything.

@piotrwitek
Copy link
Owner

Closing as implemented: bab3528

@piotrwitek piotrwitek closed this Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

investigate "strictFunctionTypes" issue
4 participants