You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
With the addition of handlingStack on the context in beforeSend, I am getting a typescript error trying to access it.
To Reproduce
Steps to reproduce the behavior:
npm install latest @datadog/browser-rum
Implement beforeSend in a typescript file
attempt to access context.handlingStack
See typescript error
Property 'handlingStack' does not exist on type 'RumActionEventDomainContext | RumFetchResourceEventDomainContext | RumXhrResourceEventDomainContext | RumOtherResourceEventDomainContext | RumErrorEventDomainContext | RumLongTaskEventDomainContext | RumVitalEventDomainContext'.
Expected behavior
No typescript error occurs when trying to access handlingStack
I understand that handlingStack does not exist on some rum event types, but for the ones where it does exist, I should be able to access that property without typescript errors.
I have tried a workaround to create a custom type that I can cast to when accessing handlingStack like so
type RumEventContextWithHandlingStack = Exclude<
RumEventDomainContext,
RumViewEventDomainContext | RumOtherResourceEventDomainContext
>;
but there are other types I would need to exclude that are only internal types.
The text was updated successfully, but these errors were encountered:
Thank you for your feedback. Before attempting to access handlingStack, you should do if ('handlingStack' in context). This is a TypeScript limitation, but maybe we could improve the developer experience by making the type less strict ... Instead of having:
Describe the bug
With the addition of
handlingStack
on the context in beforeSend, I am getting a typescript error trying to access it.To Reproduce
Steps to reproduce the behavior:
@datadog/browser-rum
beforeSend
in a typescript filecontext.handlingStack
Expected behavior
No typescript error occurs when trying to access
handlingStack
I understand that
handlingStack
does not exist on some rum event types, but for the ones where it does exist, I should be able to access that property without typescript errors.I have tried a workaround to create a custom type that I can cast to when accessing
handlingStack
like sobut there are other types I would need to exclude that are only internal types.
The text was updated successfully, but these errors were encountered: