-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3b2274
commit bc2ae38
Showing
3 changed files
with
19 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { DecreaseDepth } from "./path" | ||
import { DecreaseDepth, MaxRecursionDepth } from "./path" | ||
|
||
// We need to make decrease the depth twice as fast since we index twice in PathToField | ||
type DoubleDecrease<T extends number> = DecreaseDepth<DecreaseDepth<T>> | ||
|
||
/** | ||
* Gives the path to a field in a step. | ||
*/ | ||
export type StepPathToField = PathToField<`fields`> | ||
export type PathToField<T extends string, D extends number = 5> = | ||
export type PathToField<T extends string, D extends number = DoubleDecrease<MaxRecursionDepth>> = | ||
D extends never ? | ||
never | ||
: T | | ||
`${T}[${number}].subFields` | ||
| PathToField<`${T}[${number}].subFields`, DecreaseDepth<D>> | ||
| PathToField<`${T}[${number}].subFields`, DoubleDecrease<D>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters