I have the following code:
if (event.hasOwnProperty('body')) {
Context.request = JSON.parse(event.body) as T;
} else {
Context.request = event;
}
where event
is defined as:
private static event: aws.IGatewayEvent | ut.IGenericEvent;
The first definition has a "body" attribute, the second does not. Still I'd expect that my conditional statement should let Typescript see that the only case left -- aka, where the object implements the aws.IGatewayEvent
interface -- and not give the error:
Property 'body' does not exist on type 'IGenericEvent | IGatewayEvent'.