Created
August 21, 2018 15:40
-
-
Save anthony2025/bef26d86f9ccd269e846faf77b6f3ad6 to your computer and use it in GitHub Desktop.
Alternative to now deprecated existential type (*)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To get the return type of a function you can use this helper | |
export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>; | |
// Example of usage: | |
const mapDispatchToProps = (dispatch: Dispatch) => ({ | |
actions: { | |
setCompany: ({ companyId, domainName }) => | |
dispatch( | |
setCompany({ | |
companyId, | |
domainName, | |
}), | |
), | |
}, | |
}); | |
type ReduxActions = ExtractReturn<typeof mapDispatchToProps>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment