refactor(react): replace prototype-walking and inferred class props (#1376)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
rahim
2026-04-20 09:20:46 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 5e9a02c851
commit 2f7212028c
21 changed files with 256 additions and 176 deletions
@@ -0,0 +1,20 @@
import { isUndefined } from '@videojs/utils/predicate';
export function useSyncProps<Props extends object, Rest extends Record<string, unknown>>(
target: Props,
props: Partial<Props> & Rest,
defaults: Props
): Omit<Rest, keyof Props> {
const rest: Record<string, unknown> = {};
for (const key in props) {
if (key in defaults) {
const value = isUndefined(props[key]) ? (defaults as Record<string, unknown>)[key] : props[key];
if (target[key as keyof typeof target] !== value) target[key as keyof typeof target] = value as any;
} else {
rest[key] = props[key];
}
}
return rest as Omit<Rest, keyof Props>;
}