Skip to content

Instantly share code, notes, and snippets.

@alshdavid
Last active May 17, 2019 14:45
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 alshdavid/e74cf689b74928268fdff24e2eeb5caf to your computer and use it in GitHub Desktop.
Save alshdavid/e74cf689b74928268fdff24e2eeb5caf to your computer and use it in GitHub Desktop.
type Thing = {
data: string
printData: () => void
}
const printData = (t: Thing) => () => {
console.log(t.data)
}
const createThing = (): Thing => {
const state = {
data: 'hey'
}
return {
...state
printData: printData(state)
}
}
// Usage
const thing = createThing()
thing.printData()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment