Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbroschwitz/5d9e2f1be6365e21c54bd95e1309af0c to your computer and use it in GitHub Desktop.
Save pbroschwitz/5d9e2f1be6365e21c54bd95e1309af0c to your computer and use it in GitHub Desktop.
Master FUNCTION OVERLOADS with 'compose' - example from Matt Pocock
// See https://www.youtube.com/watch?v=D1a8OoBWi1g&list=PLIvujZeVDLMx040-j1W4WFs1BxuTGdI_b&index=10
function compose(...args: any[]) {
return {} as any;
}
const addOne = (a: number) => {
return a + 1;
}
const numToString = (a: number) => {
return a.toString();
}
const stringToNum = (a: string) => {
return parseInt(a);
}
const addOneToString = compose(addOne);
// ^ <-- const addOneToString: any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment