require function parameter to implement multiple interfaces

前端 未结 1 1167
谎友^
谎友^ 2021-01-19 09:54

In typescript, is it possible to do something of the sort:

module module1 {
    export interface Foo {
        data1: string;
    }
    export interface Bar          


        
相关标签:
1条回答
  • 2021-01-19 10:33

    You'd have to make a new named interface:

    module module1 {
        export interface Foo {
            data1: string;
        }
        export interface Bar {
            data2: string;
        }
        export interface FooAndBar extends Foo, Bar { }
        export function foobar(data: FooAndBar) {
            //do stuff
            data.data1; data.data2;
        }
    }
    
    0 讨论(0)
提交回复
热议问题