@tanstack/form-core
Advanced tools
Comparing version 0.19.1 to 0.19.2
@@ -33,12 +33,3 @@ export type RequiredByKey<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; | ||
*/ | ||
export type DeepValue<TValue, TAccessor, TDepth extends any[] = []> = TDepth['length'] extends 3 ? never : TValue extends ReadonlyArray<any> ? TAccessor extends `[${infer TBrackets}].${infer TAfter}` ? DeepValue<DeepValue<TValue, TBrackets, [...TDepth, any]>, TAfter, [ | ||
...TDepth, | ||
any | ||
]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends keyof TValue ? TValue[TAccessor] : TValue[TAccessor & number] : TValue extends Record<string | number, any> ? TAccessor extends `${infer TBefore}[${infer TEverythingElse}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, `[${TEverythingElse}`, [ | ||
...TDepth, | ||
any | ||
]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends `${infer TBefore}.${infer TAfter}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, TAfter, [ | ||
...TDepth, | ||
any | ||
]> : TAccessor extends string ? TValue[TAccessor] : never : never; | ||
export type DeepValue<TValue, TAccessor> = unknown extends TValue ? TValue : TValue extends ReadonlyArray<any> ? TAccessor extends `[${infer TBrackets}].${infer TAfter}` ? DeepValue<DeepValue<TValue, TBrackets>, TAfter> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets> : TAccessor extends keyof TValue ? TValue[TAccessor] : TValue[TAccessor & number] : TValue extends Record<string | number, any> ? TAccessor extends `${infer TBefore}[${infer TEverythingElse}` ? DeepValue<DeepValue<TValue, TBefore>, `[${TEverythingElse}`> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets> : TAccessor extends `${infer TBefore}.${infer TAfter}` ? DeepValue<DeepValue<TValue, TBefore>, TAfter> : TAccessor extends string ? TValue[TAccessor] : never : never; | ||
export {}; |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.19.1", | ||
"version": "0.19.2", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -138,1 +138,15 @@ import { assertType } from 'vitest' | ||
assertType<string>(0 as never as FormDefinitionValue) | ||
type DoubleDeepArray = DeepValue< | ||
{ | ||
people: { | ||
parents: { | ||
name: string | ||
age: number | ||
}[] | ||
}[] | ||
}, | ||
`people[${0}].parents[${0}].name` | ||
> | ||
assertType<string>(0 as never as DoubleDeepArray) |
@@ -99,8 +99,6 @@ export type RequiredByKey<T, K extends keyof T> = Omit<T, K> & | ||
TAccessor, | ||
// (Optional) An array representing the current depth of recursion | ||
TDepth extends any[] = [], | ||
> = | ||
// Limit the depth of recursion to 3 levels | ||
TDepth['length'] extends 3 | ||
? never | ||
// If TValue is any it will recurse forever, this terminates the recursion | ||
unknown extends TValue | ||
? TValue | ||
: // Check if we're looking for the property in an array | ||
@@ -113,9 +111,5 @@ TValue extends ReadonlyArray<any> | ||
*/ | ||
DeepValue< | ||
DeepValue<TValue, TBrackets, [...TDepth, any]>, | ||
TAfter, | ||
[...TDepth, any] | ||
> | ||
DeepValue<DeepValue<TValue, TBrackets>, TAfter> | ||
: TAccessor extends `[${infer TBrackets}]` | ||
? DeepValue<TValue, TBrackets, [...TDepth, any]> | ||
? DeepValue<TValue, TBrackets> | ||
: TAccessor extends keyof TValue | ||
@@ -127,15 +121,7 @@ ? TValue[TAccessor] | ||
? TAccessor extends `${infer TBefore}[${infer TEverythingElse}` | ||
? DeepValue< | ||
DeepValue<TValue, TBefore, [...TDepth, any]>, | ||
`[${TEverythingElse}`, | ||
[...TDepth, any] | ||
> | ||
? DeepValue<DeepValue<TValue, TBefore>, `[${TEverythingElse}`> | ||
: TAccessor extends `[${infer TBrackets}]` | ||
? DeepValue<TValue, TBrackets, [...TDepth, any]> | ||
? DeepValue<TValue, TBrackets> | ||
: TAccessor extends `${infer TBefore}.${infer TAfter}` | ||
? DeepValue< | ||
DeepValue<TValue, TBefore, [...TDepth, any]>, | ||
TAfter, | ||
[...TDepth, any] | ||
> | ||
? DeepValue<DeepValue<TValue, TBefore>, TAfter> | ||
: TAccessor extends string | ||
@@ -142,0 +128,0 @@ ? TValue[TAccessor] |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
379994
6341