in typescript I want to create type from array of objects
if array object is
const columns = [{key: "a"}, {key: "b"}]
// row should be
const row = {a: "", b: ""}
I do like this but why must_be_error does not show error in typescript?
export type ColumnsKeys = {
key: string,
label: string | ReactNode
}[]
type RowType<T extends ColumnsKeys> = { [K in T[number]['key']]: string | ReactNode };
const a: ColumnsKeys = [{
key: "name",
label: "hey"
}]
const columns: RowType<typeof a>[] = [{
name: "",
must_be_error: ""
}]