6

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?

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
Jason Leach
  • 3,889
  • 7
  • 37
  • 54

2 Answers2

8

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();
basarat
  • 261,912
  • 58
  • 460
  • 511
1

I am pulling in the "@types/jsreport-core": "^1.5.1" in package.json's devDependencies and am using an import, for example:

import JsReport from 'jsreport-core';

const jsReport = JsReport({
    loadConfig: true
});
andyb
  • 43,435
  • 12
  • 121
  • 150