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
-17
View File
@@ -22,20 +22,3 @@ export type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
export type NonNullableObject<T extends object> = {
[P in keyof T]-?: Exclude<T[P], null | undefined>;
};
// Detects readonly vs writable properties via conditional type identity check.
type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
type WritableKeys<T> = {
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, K, never>;
}[keyof T];
type SettableKeys<T> = {
[K in WritableKeys<T>]: T[K] extends (...args: any[]) => any ? never : K;
}[WritableKeys<T>];
type ExcludeInternal<K> = K extends `_${string}` ? never : K;
export type InferClassProps<D extends abstract new (...args: any[]) => any> = Partial<
Pick<InstanceType<D>, ExcludeInternal<SettableKeys<InstanceType<D>>>>
>;