我未能在我的JSNLog项目中从TypeScript导入JL模块。我使用JSPM安装了我的依赖项:
jspm install npm:jsnlog文档给出了一个节点示例:
var JL = require('jsnlog').JL;我试图使它在我的项目中可用(对于浏览器),但我无法使它工作:
import JL from 'jsnlog' // TypeError: jsnlog_1.default.createConsoleAppender is not a function
import {JL} from 'jsnlog' // TypeError: Cannot read property 'createConsoleAppender' of undefined
const JL = require('jsnlog').JL // Error: require is not defined
import JL = require('jsnlog').JL // TypeError: JL.createConsoleAppender is not a function有哪个巫师能把我引向正确的方向?
// tsconfig.json
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"module": "system",
"moduleResolution": "node",
"target": "es5"
}发布于 2016-02-28 14:53:21
根据JNSLog 作者
jsnlog.js实际上是用TypeScript编写的: https://github.com/mperdeck/jsnlog.js/blob/master/jsnlog.ts我使用TypeScript编译器将jsnlog.ts编译成jsnlog.js (这是纯的>JavaScript的)。
由于您的项目已经基于类型记录,所以我将使用jsnlog.d.ts文件进行导入(您可能需要自己创建这个文件)。
https://stackoverflow.com/questions/35252939
复制相似问题