What does “can only be default-imported using the 'esModuleInterop' flag” mean?

孤者浪人 提交于 2020-03-22 06:39:08

问题


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?


回答1:


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

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



来源:https://stackoverflow.com/questions/57960016/what-does-can-only-be-default-imported-using-the-esmoduleinterop-flag-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!