Skip to content

v0.0.14

Latest
Compare
Choose a tag to compare
@biw biw released this 08 Mar 01:12
9bbcbb5

This release adds support for explicit function type variable annotation

Example (also can be found in index.test.ts):

type RetType = (x: string) => WithEW<{
  a: { num: string }[]
  b: string
}>

const func: RetType = ew((err, x) => {
  if (x === 'pizza') {
    return {
      a: [{ num: '123' }],
      b: '123',
    }
  }
  return {
    a: [{ num: '123' }],
    b: '123',
  }
})

It is still recommended to use WithEW as the return type of the ew callback function (i.e. ew((err): WithEW<...> => {})) but there are some cases where this isn't ideal, such as making an interface that will be implemented.


View on NPM: https://www.npmjs.com/package/enwrap/v/0.0.14