DEV Community

Discussion on: How to UPPER_CASE to camelCase in raw Typescript generics

Collapse
 
pranavdakshina profile image
Pranav Dakshinamurthy

Is there a way handle this if the type is an array? For example:

type Sample = {
  a_1: string;
  b_1: string;
  c_1: Array<{
    a_1: string;
    b_1: string;
  }>;
};
Enter fullscreen mode Exit fullscreen mode
Collapse
 
svehla profile image
Jakub Švehla

Yep of course

you an do recursion with if statement like:

T extends any[]  ? /* ........
Enter fullscreen mode Exit fullscreen mode

I use similar technique here for recursive deep nesting
dev.to/svehla/typescript-how-to-de...

I hope it can help you somehow 🙏