如何声明实现多个接口的typescript属性

J2K*_*J2K 6 typescript

说我有2个接口:

interface Interface1{}
interface Interface2{}
Run Code Online (Sandbox Code Playgroud)

有没有办法将属性声明为实现两个接口?就像是:

class MyClass{
  public p: Interface1, Interface2
}
Run Code Online (Sandbox Code Playgroud)

bas*_*rat 7

有没有办法将属性声明为实现两个接口?就像是:

对.安intersection type:

interface Interface1{}
interface Interface2{}
class MyClass{
  public p: Interface1 & Interface2
}
Run Code Online (Sandbox Code Playgroud)

更多

这包括在这里https://basarat.gitbooks.io/typescript/content/docs/types/type-system.html