我找不到@type/{name}
我已安装的NodeJS包之一的TypeScript定义,所以我尝试为其编写d.ts
文件,然后将该文件放在{project root}\typings
文件夹中。这是我的方法:
// My source code: index.ts
import Helper from 'node-helper-lib';
// My definition: \typings\node-helper-lib.d.ts
declare....(something else)
declare module 'node-helper-lib' {
class Helper { ... }
export = Helper;
}
但是,Visual Studio Code不断产生此错误,并将红线放在下面declare module 'node-helper-lib'
:
[ts]扩充中无效的模块名称。模块'node-helper-lib'解析为'{project path} \ node_modules \ node-helper-lib \ index.js'处的未类型化模块,无法对其进行扩充。
因为该库是无类型的,所以应该允许我在其中添加类型吗?
更新:
我在用:
- 打字稿:2.1.4
- Visual Studio程式码:1.9.1
- 节点JS:6.9.4
- Windows 10 x64