Complete worked example
typescript
type LeafText<T> = T extends readonly (infer U)[] ? LeafText<U> : T extends string ? T : never;
const leaf: LeafText<readonly ["QA", readonly ["PM"]]> = "QA";- Reasoning
- The recursive rule handles only arrays of leaves and filters unsupported leaf kinds explicitly.