How to add alias to a TypeScript interface for an existing property?

Viewed 355

How can I achieve to assign the type of another property?

// 3rd party interface
interface A {
   foo: FooType
}

// my desired solution
interface B extends A {
   bar: typeof A.foo
}
1 Answers

Use square bracket notation: A['foo']

// 3rd party interface
interface A {
   foo: FooType
}

// my desired solution
interface B extends A {
   bar: A['foo'] // here is the solution
}
Related