[英]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.