Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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
Typescript 找不到名称';X';,即使名称是直接在上面导入的_Typescript_Angular - Fatal编程技术网

Typescript 找不到名称';X';,即使名称是直接在上面导入的

Typescript 找不到名称';X';,即使名称是直接在上面导入的,typescript,angular,Typescript,Angular,我不确定这里到底发生了什么。这个名字显然是直接在上面输入的 以下是存储后端.interface.ts的内容: export declare interface StorageBackend extends Storage { } 发生了什么事?您不能将接口用于提供程序令牌,因为它们在运行时不存在。您需要使用类、字符串或OpqueToken 否则,我将尝试以下方法: export interface StorageBackend extends Storage { } declare关键字是

我不确定这里到底发生了什么。这个名字显然是直接在上面输入的

以下是
存储后端.interface.ts
的内容:

export declare interface StorageBackend extends Storage { }

发生了什么事?

您不能将接口用于提供程序令牌,因为它们在运行时不存在。您需要使用类、字符串或
OpqueToken

否则,我将尝试以下方法:

export interface StorageBackend extends Storage { }
declare
关键字是“declare”一个元素,但在定义文件(
.d.ts
)中,而不是在TypeScript模块本身中