0

这个问题很简单。

这是模块导出函数的方式。

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

4

1 回答 1

0

我发现它通过文档挖掘

const log = debug('http');
log.log = console.log.bind(console); // binding to console
于 2016-09-04T02:26:05.013 回答