Skip to content

Instantly share code, notes, and snippets.

@agentbellnorm
Last active April 13, 2021 08:03
Show Gist options
  • Save agentbellnorm/494312bafa1b3033ff0e02d405cd601a to your computer and use it in GitHub Desktop.
Save agentbellnorm/494312bafa1b3033ff0e02d405cd601a to your computer and use it in GitHub Desktop.
clojure's swap function in typescript with proper typing.
swap<K extends unknown[]>(swapFunction: (state: T, ...args: K) => T, ...args: K): T {
this.state = swapFunction.apply(null, [this.state, ...args]);
return this.state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment