Skip to content

Commit

Permalink
fix(types): remove deep path autocompletion
Browse files Browse the repository at this point in the history
It was causing infinite typing loop.
  • Loading branch information
gregberge committed Apr 15, 2022
1 parent fa48e04 commit e01e8b3
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/system/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,22 @@ export interface TransformValue {
): CSSScalar
}

declare type SynthesizedPath<T extends {}> = {
[P in keyof T]:
| (T[P] extends { [key: string]: any; [key: number]: any }
? `${string & P}` | `${string & P}.${SynthesizedPath<T[P]>}`
: `${string & P}`)
| (number & P)
}[T extends any[] ? number & keyof T : keyof T]

export type ThemeNamespaceValue<
K extends string,
T extends ITheme,
> = SynthesizedPath<T[K]>
// declare type SynthesizedPath<T> = {
// [P in keyof T]:
// | (T[P] extends { [key: string]: any; [key: number]: any }
// ? `${string & P}` | `${string & P}.${SynthesizedPath<T[P]>}`
// : `${string & P}`)
// | (number & P)
// }[T extends any[] ? number & keyof T : keyof T]

// export type ThemeNamespaceValue<
// K extends string,
// T extends ITheme,
// > = SynthesizedPath<T[K]>

export type ThemeNamespaceValue<K extends string, T extends ITheme> =
| NamespaceType<T[K]>
| {}

export interface ThemeGetter<T = any> {
(value: T, defaultValue?: CSSScalar): (props: Props<Theme>) => CSSScalar
Expand Down

1 comment on commit e01e8b3

@quantizor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregberge can you comment on situations where this was happening? We have a fairly complex setup at @aurorasolar and haven't run into infinite loops with this functionality...

Please sign in to comment.