【发布时间】:2017-02-05 10:52:42
【问题描述】:
我已使用以下命令将 .d.ts 文件(即 p2.js 库的类型定义)安装为外部(非全局)typings 模块:
typings install p2=github:schteppe/p2.js/index.d.ts#9d56924
然后我在我的 TypeScript 代码中使用它,如下所示:
import * as p2 from 'p2';
此导入出现在已编译的 javascript 中:
var p2 = require('p2');
但是,显然我不需要它,因为p2 外部模块只包含类型定义,而不包含实际代码。然后我在 TypeScript 的输出上运行webpack,它无法编译
...Module not found: Error: Cannot resolve module 'p2'...
使用这个外部模块的正确方法是什么,以便 TypeScript 和我的 IDE(带有 atom-typescript 插件的 Atom)看到定义,但没有 require 调用它被包含在 TypeScript 输出中?
【问题讨论】:
标签: javascript typescript webpack typescript-typings