PathValue<T, P extends string>
typeResolves the value type at a dotted path P inside object/array T.
Supports numeric segments for array indexing (e.g., "items.0.title").
The empty path resolves to
T itself, matching what the code has always done: both the
store's internal path reader and the React one return the object unchanged for "". The type
used to say never, so a subscription to a root-value slice was typed as nothing at all.Definition
type
type PathValue<T, P extends string> = P extends "" ? T : P extends `${K}.${Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : K extends `${number}` ? T extends readonly E[] ? PathValue<E, Rest> : never : never : P extends keyof T ? T[P] : P extends `${number}` ? T extends readonly E[] ? E : never : neverP extends "" ? T : P extends `${K}.${Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : K extends `${number}` ? T extends readonly E[] ? PathValue<E, Rest> : never : never : P extends keyof T ? T[P] : P extends `${number}` ? T extends readonly E[] ? E : never : never
Type parameters
| Name | Type | Description |
|---|---|---|
T | — | Root type to index into. |
P | extends string | Dotted path string. |