Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save silviogutierrez/01e22a741b6822ec8925116b0d34231b to your computer and use it in GitHub Desktop.
Save silviogutierrez/01e22a741b6822ec8925116b0d34231b to your computer and use it in GitHub Desktop.
function decorateEntrySnippet<Additions, I>(someFunctionThatReturnsAdditions: () => Additions, toDecorate: (props: I) => void) {
function inside(props: I & Additions) {
return toDecorate(props);
}
return inside;
}
function EntrySnippet(props: {entry: Entry}): void {
}
const generateAdditions = () => {
return {
entry: 'Clearly this should not work',
};
}
const DecoratedEntrySnippet = decorateEntrySnippet(generateAdditions, EntrySnippet);
let myEntry: Entry = null;
let myMeal: Meal = null;
EntrySnippet({entry: myEntry})
DecoratedEntrySnippet({entry: myEntry})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment