I am trying to write a generic interface which accepts two types, something returned by Entry, T and the key, K which contains this.
I am not sure if this is something that can be done using typescript.
Does anyone know? Thanks!
// this is a bad way of doing it
export interface Reconfigure<T> {
title: string
keyOne?: Entry<T>[]
keyTwo?: Entry<T>[]
keyThree?: Entry<T>[]
keyFour?: Entry<T>[]
}
// this is close to what I'd want to do, but doesn't work
export interface Reconfigure<T, K> {
title: string
[K]: Entry<T>[]
}
type Reconfigure<T, K> = { [key in K]: Entry<T> }but not sure if you can get it working as nicely as an interface.foo: Entry<T>[]}..