My current configuration is as follows:
const foo = async <T>(a): Promise<T> => {
return await a // call server here
}
type A = { bar: 'bar' } | { baz: 'baz' }
foo<A>({ bar: 'bar' })
.then(response => {
// error: property bar doesn't exist on type { baz: 'baz' }
if (response.bar) console.log('bar')
// error: property baz doesn't exist on type { bar: 'bar' }
if (response.baz) console.log('baz')
})
Do you think this issue lies with TypeScript or my particular setup?