diff --git a/src/public/types/keypaths.d.ts b/src/public/types/keypaths.d.ts index 4b13ed04b..51d5c1fc8 100644 --- a/src/public/types/keypaths.d.ts +++ b/src/public/types/keypaths.d.ts @@ -1,16 +1,17 @@ export type KeyPaths = { - [P in keyof T]: - P extends string - ? T[P] extends Array - ? K extends object // only drill into the array element if it's an object - ? P | `${P}.${number}` | `${P}.${number}.${KeyPaths}` - : P | `${P}.${number}` - : T[P] extends (...args: any[]) => any // Method - ? never - : T[P] extends object - ? P | `${P}.${KeyPaths}` - : P - : never; + [P in keyof T]: P extends string + ? T[P] extends Array + ? K extends any[] // Array of arrays (issue #2026) + ? P | `${P}.${number}` | `${P}.${number}.${number}` + : K extends object // only drill into the array element if it's an object + ? P | `${P}.${number}` | `${P}.${number}.${KeyPaths}` + : P | `${P}.${number}` + : T[P] extends (...args: any[]) => any // Method + ? never + : T[P] extends object + ? P | `${P}.${KeyPaths}` + : P + : never; }[keyof T]; export type KeyPathValue = PATH extends `${infer R}.${infer S}` diff --git a/test/typings-test/test-typings.ts b/test/typings-test/test-typings.ts index cb05c9010..88d1cd49a 100644 --- a/test/typings-test/test-typings.ts +++ b/test/typings-test/test-typings.ts @@ -268,12 +268,17 @@ import './test-updatespec'; isGoodFriend: boolean; address: { city: string; - } + }, + matrix: number[][]; // Trigger issue #2026 } let db = new Dexie('dbname') as Dexie & {friends: Table}; db.friends.where({name: 'Kalle'}).modify({name: replacePrefix('K', 'C')}); + + // Issue #2026 + db.friends.update(1, {"address.city": "New York"}); + db.friends.update(2, {matrix: [[1,2]]}); }