在项目.d.ts定义文件中使用@types定义

时间:2017-05-09 08:27:25

标签: typescript types node-modules

我试图为我的项目编写一个.d.ts文件来定义一些全局接口。 但是我在该定义文件中使用非全局库类型时遇到问题。 特别是我试图引用的RxJ对我不起作用。

我认为最好的方法是使用三斜杠参考标记来导入RxJ的类型,但这并不起作用。

/// <reference types="rxjs" />

interface IUserService {
    user$: rxjs.Observable<IUser>;
}

1 个答案:

答案 0 :(得分:2)

我找到了我想做的解决方案:

declare global { }

使用$command = escapeshellcmd("python /home/forge/default/pdf.py " . $id); $output = shell_exec($command); 我能够回到全局命名空间。 Typescript真的缺少这个有用指令的文档,只在本页末尾略有说明:https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation