So I have this type called TranslationsData
:
[key: string]: { translation: { state: AnotherType } };
I want to use this part:
[key: string]: { translation: { state:
in another type, so the only type that changes is the AnotherType
part.
Is there a way to do it? Kind of higher order type.
I know there is smth like this Type, but I have no idea what it's called.
CodePudding user response:
The cleanest option in this case would be to make the initial type generic, something like the following.
type Foo<T> = {
[key: string]: { translation: { state: T } }
}
type TranslationsData = Foo<AnotherType>
type SomethingElse = Foo<Bar>