什么是“只能使用'esModuleInterop'标志默认导入"?意思是? [英] What does "can only be default-imported using the 'esModuleInterop' flag" mean?
本文介绍了什么是“只能使用'esModuleInterop'标志默认导入"?意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到以下错误:
lib/app.ts:1:8 - error TS1259: Module '"mongoose-sequence"' can only be default-imported using the 'esModuleInterop' flag
在以下代码行上:
import _ from 'mongoose-sequence';
现在,我很高兴地承认我在整个下划线作为函数名"中缺少了某些东西,但是该错误没有任何意义,因为esModuleInterop
标志是绝对设置为true
的绝对值.在我的ts.config文件中.
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 = _;
来自猫鼬序列的DefinitelyTyped定义.
from the mongoose-sequence DefinitelyTyped definition.
我想念什么?
推荐答案
尝试使用:import _ = require('mongoose-sequence');
https://www.typescriptlang .org/docs/handbook/modules.html#export--和导入--require
这篇关于什么是“只能使用'esModuleInterop'标志默认导入"?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文