I have a typescript interface that represent my data in database, like :
interface Foo {
bar: {
fish: {
_id: string,
name: string,
}[],
},
starwars: string[],
}
I would like to be able to reference parts of this interface. In the following example, I want to pass the data behind the key fish as parameters.
I succedded to make it work doing :
interface Fish {
_id: string,
name: string,
}
interface Foo {
bar: {
fish: Fish[],
},
starwars: string[],
}
function killTheFish(fish: Fish) { ... }
But I would prefer doing something like :
type Fish = Foo.bar.fish;
Do you know any way to reference a part of an interface ?