【发布时间】:2021-07-10 19:49:43
【问题描述】:
我有以下端点设置来在测试运行后重置数据库:
import { getConnection } from 'typeorm';
import express from 'express';
const router = express.Router();
const resetDatabase = async (): Promise<void> => {
const connection = getConnection();
await connection.dropDatabase();
await connection.synchronize();
};
// typescript-eslint throws an error in the following route:
router.post('/reset', async (_request, response) => {
await resetTestDatabase();
response.status(204).end();
});
export default router;
自 async 以来的整个路线都带有 typescript-eslint 错误 Promise returned in function argument where a void return was expected. 下划线
该应用程序运行良好,但我不确定是否应该进行更安全的实施,或者只是忽略/禁用 Eslint。知道该代码有什么问题吗?
【问题讨论】:
-
我把它放到 Typescript 操场上,它编译没有任何错误,所以我认为代码没有任何问题。也许如果您分享您的 linting 配置,我们可以深入了解它。
-
实际上从头开始,我已经检查了导致这种情况的 linting 规则,我会写一个正确的答案
标签: node.js typescript eslint typeorm express-router