-
Notifications
You must be signed in to change notification settings - Fork 144
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
💥 remove Object.* Polyfills #2908
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v6 #2908 +/- ##
==========================================
- Coverage 93.76% 93.76% -0.01%
==========================================
Files 267 267
Lines 7378 7372 -6
Branches 1659 1658 -1
==========================================
- Hits 6918 6912 -6
Misses 460 460 ☔ View full report in Codecov by Sentry. |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
636aba9
to
72edfea
Compare
@@ -161,7 +160,7 @@ type GenericBeforeSendCallback = (event: any, context?: any) => unknown | |||
*/ | |||
type ProxyFn = (options: { path: string; parameters: string }) => string | |||
|
|||
interface ReplicaUserConfiguration { | |||
export interface ReplicaUserConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks weird but it's because this some type is inferred as ReplicaUserConfiguration
in another module (remoteConfiguration.ts) but typescript can't name it.
@datadog/browser-rum-core: src/domain/configuration/remoteConfiguration.ts(22,17): error TS4058: Return type of exported function has or is using name 'ReplicaUserConfiguration' from external module "/Users/thomas.lebeau/go/src/github.com/DataDog/browser-sdk/packages/core/cjs/domain/configuration/configuration" but cannot be named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assign({}, initConfiguration, remoteInitConfiguration)
return type is the intersection of RumInitConfiguration and RumRemoteConfiguration. So ReplicaUserConfiguration is not exposed.
And I think that { ...initConfiguration, ...remoteInitConfiguration }
export a new type containing all the props from both object types, including non exported ReplicaUserConfiguration.
Maybe that's the reason.
export function shallowClone<T>(object: T): T & Record<string, never> { | ||
return assign({}, object) | ||
return { ...object } as T & Record<string, never> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow, if T
is undefined
, then TS will infer {...object}
as undefined
, insead of {}
see TS playground
@@ -315,23 +314,21 @@ function newClick( | |||
} | |||
|
|||
const { resourceCount, errorCount, longTaskCount } = eventCountsSubscription.eventCounts | |||
const clickAction: ClickAction = assign( | |||
{ | |||
type: ActionType.CLICK as const, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type
is unnecessary here, actually TS errors with: 'type' is specified more than once, so this usage will be overwritten. ts(2783)
spreading clickActionBase
will always overwrites type
@@ -161,7 +160,7 @@ type GenericBeforeSendCallback = (event: any, context?: any) => unknown | |||
*/ | |||
type ProxyFn = (options: { path: string; parameters: string }) => string | |||
|
|||
interface ReplicaUserConfiguration { | |||
export interface ReplicaUserConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assign({}, initConfiguration, remoteInitConfiguration)
return type is the intersection of RumInitConfiguration and RumRemoteConfiguration. So ReplicaUserConfiguration is not exposed.
And I think that { ...initConfiguration, ...remoteInitConfiguration }
export a new type containing all the props from both object types, including non exported ReplicaUserConfiguration.
Maybe that's the reason.
Motivation
Removed unnecessary polyfills for v6, resulting in a slight improvement in the bundle sizes.
Changes
objectValues
andobjectEntries
polyfills. However I'm keeping the wrapper method because their mangling result in smaller bundle size than usingObject.values()
every time it is used.Object.assign
polyfills in favor of object spread operator.Testing
I have gone over the contributing documentation.