dot-diver icon indicating copy to clipboard operation
dot-diver copied to clipboard

Paths of properties of an object with index signature gets truncated.

Open djfhe opened this issue 2 years ago • 0 comments

See title. If we have a object inside a object with an index signature, all paths of the nested objects are getting truncated.

Example:

type TestType = {
    [index: string]: {
        a: string
        b: number
    }
}

// should be string | number | `${string}.a` | `${string}.b`
// but is string | number
type Paths = Path<TestType>

Typescript simplifies unions of string and template literals to only string, which truncates the template literals. There are ways to fix this (using (string & {}) instead of just string) but these would damage readability of code auto completion or error messages.

djfhe avatar Mar 24 '23 20:03 djfhe