Search code examples
node.jstypescriptrequirejsreport

What is the TypeScript equivalent to `var x = require("somemod")();`


In node.js I'm using jsreport-core and they do their import like var jsreport = require('jsreport-core')(); with the trailing (). I'm curious what is the best way to replicate this import technique is in TypeScript?


Solution

  • I'm curious what the best way to replicate this import technique is in TypeScript

    You need to split the import and the function call:

    import jsreportCreator = require('jsreport-core');
    const jsreport = jsreportCreator();