10

I am getting the following error:

lib/app.ts:1:8 - error TS1259: Module '"mongoose-sequence"' can only be default-imported using the 'esModuleInterop' flag

on the following line of code:

import _ from 'mongoose-sequence';

Now, I'm happy to admit I'm missing something with the whole "underscore as a function name" thing, but the error makes no sense, as the esModuleInterop flag is absolutely, positively set to true in my ts.config file.

I am trying to import this:

declare module 'mongoose-sequence' {
  import mongoose = require('mongoose');
  var _: (schema: mongoose.Schema, options?: Object) => void;
  export = _;

from the mongoose-sequence DefinitelyTyped definition.

What am I missing?

Nick Hodges
  • 16,902
  • 11
  • 68
  • 130

1 Answers1

8

Try with: import _ = require('mongoose-sequence');

https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

Johnny Zabala
  • 2,285
  • 1
  • 12
  • 14