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