Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Inheritance 在typescript中使用具有不同名称空间的接口_Inheritance_Interface_Typescript_Namespaces - Fatal编程技术网

Inheritance 在typescript中使用具有不同名称空间的接口

Inheritance 在typescript中使用具有不同名称空间的接口,inheritance,interface,typescript,namespaces,Inheritance,Interface,Typescript,Namespaces,我想在“parent.a”命名空间中创建一个接口,我想在“parent”命名空间中使用该接口 有没有办法,请帮我一下 我找到了一种从不同名称空间访问类的解决方案,但我需要使用接口而不是类 我的例子是: module Parent.AInterface { export interface AInterface { setParent(): void; } } 我的另一个模块 module Parent { export class Par

我想在“parent.a”命名空间中创建一个接口,我想在“parent”命名空间中使用该接口

有没有办法,请帮我一下

我找到了一种从不同名称空间访问类的解决方案,但我需要使用接口而不是类

我的例子是:

module Parent.AInterface {    

    export interface AInterface {
        setParent(): void;
    }

} 
我的另一个模块

module Parent {

    export class ParentClass implements AInterface {

    }

}
在这样做的同时。。我收到一个错误,显示找不到名称“AInterface”


请在这方面帮助我。

您应该在接口名称之前提到模块名称:

module Parent.AInterface {    

    export interface AInterface {
        setParent(): void;
    }

} 


module Parent {

    export class ParentClass implements AInterface.AInterface {
        setParent() {
        }
    }

}
这对我在typescript操场上很有用。

Parent.ts

///<reference path="./Parent.AInterface.ts" />
module Parent {
     export class ParentClass implements AInterface.AInterface {}
}
///
模块父级{
导出类ParentClass实现AInterface.AInterface{}
}

两个模块是否在不同的文件中声明?如果是这样,您是否尝试过在第二个类中添加类似于´//´的内容,即模块父级?