Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ref(utils): Clean up dangerous type casts in object helper file #5047

Merged
merged 2 commits into from
May 9, 2022

Conversation

lforst
Copy link
Member

@lforst lforst commented May 6, 2022

While trying to understand what convertToPlainObject does, I noticed that it had some pretty dangerous type signatures. This PR tries to clean that up a bit.

This PR intends not change any behaviour.

@lforst lforst force-pushed the lforst-object-cleanup branch from e38d12f to 78f733e Compare May 6, 2022 13:15
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 18.72 KB (-7.06% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 58.53 KB (-9.41% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.53 KB (-7.08% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 52.71 KB (-9.07% 🔽)
@sentry/browser - Webpack (gzipped + minified) 19.19 KB (-17.42% 🔽)
@sentry/browser - Webpack (minified) 62.07 KB (-24.04% 🔽)
@sentry/react - Webpack (gzipped + minified) 19.21 KB (-17.46% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 42.74 KB (-11.07% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 24.4 KB (-6.44% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 22.98 KB (-6.16% 🔽)

@lforst lforst force-pushed the lforst-object-cleanup branch from 78f733e to d8023f9 Compare May 6, 2022 15:14
[key: string]: unknown;
};

export function convertToPlainObject<V extends unknown>(value: V): Record<string, unknown> | V {
Copy link
Member

Choose a reason for hiding this comment

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

we can maybe type this return values more strongly (and union type the various returns)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done: 9552a75

@lforst lforst marked this pull request as ready for review May 9, 2022 08:03
@lforst lforst merged commit 8d475b1 into 7.x May 9, 2022
@lforst lforst deleted the lforst-object-cleanup branch May 9, 2022 08:26
@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants