【发布时间】:2016-03-13 14:38:37
【问题描述】:
试图包含 sax 解析器并遇到困难 [parser.ts]。
import sax = require("sax");
export class MyParser {
//my parser code
}
当我尝试使用它时[app.component.ts]:
import {MyParser} from './parser'
...
constructor(private http: Http, private parser: MyParser) {}
我收到此错误
Evaluating http://localhost:3000/sax
我知道这意味着 SystemJS 找不到模块。 Sax 安装在 node_modules 中并列在 package.json 中。我已经安装了打字使用
typings install --ambient sax
但即使我的 tsconfig.json 不包括在内,也会收到大量重复标识符警告
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
最后,isaacs 在他的示例中使用了这样的代码
tag.parent
tag.children
键入 (d.ts) 不支持此功能。
有人用 TS 和 ng2 安装 sax 吗?
【问题讨论】:
-
代码看起来不错,可能是你配置SystemJS的方式有问题?
标签: json typescript angular sax