[英]TS2614: Module has no exported member 'NextHandleFunction'
Error:
node_modules/@types/body-parser/index.d.ts:14:10 - error TS2614: Module '"../../../src/connect"' has no exported member 'NextHandleFunction'. Did you mean to use 'import NextHandleFunction from "../../../src/connect"' instead? 14 import { NextHandleFunction } from 'connect';
I'm trying to use typescript into my nodejs project instead of javascript.我正在尝试在我的 nodejs 项目中使用 typescript 而不是 javascript。 I have followed a few tutorials and looked into some Github repositories, even though I'm getting this weird while compiling, but my server is getting started.
我遵循了一些教程并查看了一些 Github 存储库,即使我在编译时遇到了这个奇怪的问题,但我的服务器正在启动。
import * as mongoose from 'mongoose';
type TInput = {
db: string;
}
export default ({db}: TInput) => {
const connect = () => {
mongoose
.connect(
db,
{ useNewUrlParser: true }
)
.then(() => {
return console.info(`Successfully connected to ${db}`);
})
.catch(error => {
console.error('Error connecting to database: ', error);
return process.exit(1);
});
};
connect();
mongoose.connection.on('disconnected', connect);
};
try this compiler option inside tsconfig.json在 tsconfig.json 中尝试这个编译器选项
"skipLibCheck": true,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.