[英]Invoking an exported function from module in TypeScript
这个问题很简单。
这是模块导出功能的方式。
exports = module.exports = debug.debug = debug;
这是ES5模块使用它的方式。
var debug = require('debug')('http')
现在在Typescript中有所不同。
import * as debug from 'debug';
这将返回一个我从未见过的奇怪对象,一个没有键值对的嵌套对象。
{ [Function: debug]
coerce: [Function: coerce],
disable: [Function: disable],
// More properties go here
}
如何调用功能debug
我发现它深入文档中
const log = debug('http');
log.log = console.log.bind(console); // binding to console
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.