Hey All,
Dgraph-JS does not seem to offer a default export, so it’s fails silently with typescript if --esModuleInterop is set.
Here is a minimal example:
First, what I expect from the javascript
const dgraph = require("dgraph-js");
console.log(dgraph); // This outputs a bunch of classes
Now let’s look at the same thing from typescript
import dgraph from 'dgraph-js';
console.log(dgraph); // This outputs undefined
Here is the command to compile:
tsc --module commonjs --moduleResolution node --esModuleInterop true foo.ts
Do note that compilation fails if esModuleInterop is set to false, as there is no default export (but then other modules work correctly with esModuleInterop also fail)
This is super annoying because it makes it very difficult to port from javascript to typescript