Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 4b3936e

Browse files
authored
Fixed Pxth for arrays (#17)
1 parent e324297 commit 4b3936e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/Pxth.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,25 @@ export type PrimitivePxth<V> = {
2121
: typeof UnknownPxthBrand;
2222
};
2323

24-
export type ObjectPxth<V extends object> = {
25-
[K in keyof V]: Pxth<V[K]>;
26-
} & {
24+
type WithoutMethodsKeys<V extends object> = {
25+
[K in keyof V]: V[K] extends Function ? never : K;
26+
}[keyof V];
27+
28+
type RecordOfPxth<V extends object> = {
29+
[K in WithoutMethodsKeys<V>]: Pxth<V[K]>;
30+
};
31+
32+
export type ObjectPxth<V extends object> = RecordOfPxth<V> & {
2733
[BrandKey]: typeof ObjectPxthBrand;
2834
};
2935

3036
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31-
export type ArrayPxth<V extends Array<any>> = Array<Pxth<V[number]>> & {
32-
[BrandKey]: typeof ArrayPxthBrand;
33-
};
37+
export type ArrayPxth<V extends Array<any>> = {
38+
[K in number]: Pxth<V[number]>;
39+
} &
40+
RecordOfPxth<Omit<Array<V[number]>, number>> & {
41+
[BrandKey]: typeof ArrayPxthBrand;
42+
};
3443

3544
export type Pxth<V> = {
3645
[ObjectBrandKey]: 'brand';

0 commit comments

Comments
 (0)