Is there any way to declare a variable with the type of another variable? For instance, I declare a class member with some type, and then later I want to declare another variable in a function of the same type. But I don't want to modify the original declaration, and don't want to duplicate it. It seems like you should be able to do something like:
class Foo {
bar: {[key: string]: string[]};
func() {
const x: TypeOf<Foo.bar> = {};
....
}
}
I've heard of something like this specifically for return types of functions, but I can't find it anymore...
const x: Foo["bar"] = ...to determine the type.