Skip to content

Commit 34f6ebc

Browse files
author
Samuel Hobl
committed
Revert "feat(interpolate): improve types for nested objects"
This reverts commit 1533de7. It resulted into the following error: `Type instantiation is excessively deep and possibly infinite.ts(2589) error is thrown.` which has been issued here: microsoft/TypeScript#41406 Going to remove this until its clear what the cause is.
1 parent 1533de7 commit 34f6ebc

File tree

2 files changed

+4
-82
lines changed

2 files changed

+4
-82
lines changed

packages/interpolate/src/interpolate.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
Matchers,
1616
Variants,
1717
CSSProperties,
18-
Paths,
1918
} from './types';
2019

2120
export type Theme = Partial<ThemeOrAny>;
@@ -36,13 +35,10 @@ type ResolveAlias<
3635

3736
type ScaleKeys<Property> = LiteralUnion<
3837
Extract<
39-
Paths<
40-
ThemeOrAny['scales'][ThemeOrAny['matchers'][Extract<Property, Matchers>]]
41-
>,
42-
// keyof ThemeOrAny['scales'][ThemeOrAny['matchers'][Extract<
43-
// Property,
44-
// Matchers
45-
// >]],
38+
keyof ThemeOrAny['scales'][ThemeOrAny['matchers'][Extract<
39+
Property,
40+
Matchers
41+
>]],
4642
ValueOf<ScopedCSSProperties>
4743
>,
4844
ValueOf<ScopedCSSProperties>

packages/interpolate/src/types.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -12,77 +12,3 @@ export type Matchers = Tokens<'matchers'>;
1212
export type Shorthands = Tokens<'shorthands'>;
1313
export type Aliases = Tokens<'aliases'>;
1414
export type Variants = LiteralUnion<Tokens<'variants'>, string>;
15-
16-
export type Join<K, P> = K extends string | number
17-
? P extends string | number
18-
? `${K}${'' extends P ? '' : '.'}${P}`
19-
: never
20-
: never;
21-
22-
type Prev = [
23-
never,
24-
0,
25-
1,
26-
2,
27-
3,
28-
4,
29-
5,
30-
6,
31-
7,
32-
8,
33-
9,
34-
10,
35-
11,
36-
12,
37-
13,
38-
14,
39-
15,
40-
16,
41-
17,
42-
18,
43-
19,
44-
20,
45-
...0[]
46-
];
47-
48-
export type Paths<T, D extends number = 10> = [D] extends [never]
49-
? never
50-
: T extends object // eslint-disable-line @typescript-eslint/ban-types
51-
? {
52-
[K in keyof T]-?: K extends string | number
53-
? `${K}` | Join<K, Paths<T[K], Prev[D]>>
54-
: never;
55-
}[keyof T]
56-
: '';
57-
58-
// type NestedObjectType = {
59-
// a: string;
60-
// b: string;
61-
// colors: {
62-
// primary: 'tomato';
63-
// secondary: 'cyan';
64-
// gray: [
65-
// '#F8F9F9',
66-
// '#EDEFF1',
67-
// '#DDE0E4',
68-
// '#CBD1D6',
69-
// '#B2BAC2',
70-
// '#939BA3', // base
71-
// '#7A838C',
72-
// '#636d75',
73-
// '#515961',
74-
// '#343b40',
75-
// ];
76-
// };
77-
// nest: {
78-
// c: string;
79-
// };
80-
// otherNest: {
81-
// c: string;
82-
// };
83-
// };
84-
// type NestedObjectPaths1 = Paths<NestedObjectType>;
85-
// type NestedObjectPaths2 = keyof NestedObjectType;
86-
//
87-
// const x: NestedObjectPaths2 = 'nest';
88-
// console.log(x);

0 commit comments

Comments
 (0)