问题
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