Skip to content

Convert @bugsnag/core/lib/metadata-delegate to TypeScript #2437

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: integration/typescript
Choose a base branch
from

Conversation

AnastasiiaSvietlova
Copy link
Contributor

@AnastasiiaSvietlova AnastasiiaSvietlova commented May 12, 2025

Goal

Convert @bugsnag/core/lib/metadata-delegate to TypeScript

Testing

Covered by existing end to end and unit tests

@AnastasiiaSvietlova AnastasiiaSvietlova changed the base branch from next to integration/typescript May 12, 2025 12:22
@AnastasiiaSvietlova AnastasiiaSvietlova changed the title Convert @bugsnag/core/lib/iserrormetadata delegate Convert @bugsnag/core/lib/metadata-delegate to TypeScript May 12, 2025
Copy link

github-actions bot commented May 12, 2025

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 81.49 kB 18.78 kB
After 81.34 kB 18.68 kB
± -156 bytes -94 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against 93ade0e

@AnastasiiaSvietlova AnastasiiaSvietlova marked this pull request as ready for review May 12, 2025 13:39
Comment on lines 4 to 6
add: (state: { [key: string]: any }, section: string, keyOrObj?: any, maybeVal?: any) => any
get: (state: { [key: string]: any }, section: string, key?: any) => any
clear: (state: { [key: string]: any }, section: string, key?: any) => any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just double check what these instances of any should be? for example key looks like it should only be string or undefined according to the get function, and section should probably be unknown

Copy link
Contributor Author

@AnastasiiaSvietlova AnastasiiaSvietlova May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked it's usage in other parts of the code. So we use metadataDelegate in client.ts and event.ts. Since these files are already converted to TS, I took them as a source of possible types.
Based on what you're wrote I will change the type of key to string | undefined and in client.ts too.
But the section is always string 🤔

interface MetadataDelegate {
add: (state: { [key: string]: any }, section: string, keyOrObj?: object | string, maybeVal?: any) => any
get: (state: { [key: string]: any }, section: string, key?: string | undefined) => any
clear: (state: { [key: string]: any }, section: string, key?: string | undefined) => any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the question mark in key?: string also allows for undefined so that's probably fine as it was.

gingerbenw
gingerbenw previously approved these changes May 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants