for an object kind of like this? I want the value's name property to be the same as the key, e.g. {'a': {name: 'a'}}.
interface Foo {
[key: string]: {name: key};
}
Bump
Would this work? type Foo<T> = { [K in keyof T]: { name: K } }
I don't, that's why I want the type safety when a new property is added to Foo to make sure the name property of the value is the same as the key.
If I try to use it, what type for T do I give to Foo when I try to use it?
What do you need this for?
A project I'm contributing to. There's a large object that maps strings to values, but the name property of the value should equal the string key.
Foo<Movepool> here
Обсуждают сегодня