NextAuth 中“any”的不安全分配(选项:AuthOptions)

问题描述 投票:0回答:1

我在 Next-Auth (4.24.6) 中收到以下代码片段的 typescript/eslint 错误。我该如何解决这个问题?

Unsafe assignment of an `any` value.eslint@typescript-eslint/no-unsafe-assignment
(alias) NextAuth(options: AuthOptions): any (+2 overloads)
import NextAuth
import NextAuth from "next-auth";

import { authOptions } from "@/server/auth";

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
typescript next.js eslint next-auth
1个回答
0
投票

尝试更改导出:

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };

至:

export default NextAuth(authOptions);

因此您没有分配从 NextAuth 函数返回的值。

© www.soinside.com 2019 - 2024. All rights reserved.