#How to value, type T[keyof T] not assignable to string for value?
12 messages · Page 1 of 1 (latest)
values is a string[]
so value must be a string
so entry[colName] must be a string too
so entry must be a Record<unknown, string>
which it probably isn't
hence the error
how can i type entry then if I typed data as a generic type, im trying to avoid value: any. The suggestion Record<unknown, string> didnt work
how about
Preview:```ts
declare type dbThunkFunction = unknown
export async function update<T>(
t: dbThunkFunction,
table: string,
columns: Array<keyof T>,
data: T[]
) {
const values = data
.map(entry =>
columns.map(colName => entry[colName])
)
.flat()
}```
You can choose specific lines to embed by selecting them before copying the link.