DEV Community

Discussion on: I need to learn about TypeScript Template Literal Types

Collapse
 
phillyx profile image
Phillyx

Hey Craig, when I use Interface, it is not working on Array.Number

// This is not working
setData(person, 'cars.1.brand', 'BYD-YUAN')
Enter fullscreen mode Exit fullscreen mode

here is the code

Looking forward to Ur help

Collapse
 
phillyx profile image
Phillyx • Edited

Thx to @nroboto . Finally I've solved type-safe array dot notation.

here is the code-intelligence

See here

Collapse
 
phillyx profile image
Phillyx

Update for derivation of array types
type SubArrayPath

= P extends PropertyKey ? ${number} : ${number} | ${number}.${PathTemp<P>}