即使键入函数,我在导入的函数上也出现 no-unsafe-call 和 no-unsafe-assignment eslint 错误

I'm Getting no-unsafe-call and no-unsafe-assignment eslint error on imported function even though function is typed

我在导入类型化函数时收到 no-unsafe-call 和 no-unsafe-assignment eslint 错误。如果该函数在同一个文件中声明,则错误消失。似乎eslint无法获取导入函数的return类型。

在useWorkspaceMessages.ts

export interface WorkspaceMessage {
  message: string;
  created: string;
}

export default function useWorkspaceMessages(): WorkspaceMessage[] {
  return [];
}

在app.tsx

import useWorkspaceMessages, {
  WorkspaceMessage,
} from 'useWorkspaceMessages';

const workspaceMessages: WorkspaceMessage[] = useWorkspaceMessages();
     ^^^^^^^^^^^^^^^^^^^                      ^^^^^^^^^^^^^^^^^^^^
error  Unsafe assignment of an any value  @typescript-eslint/no-unsafe-assignment
error  Unsafe call of an any typed value  @typescript-eslint/no-unsafe-call

如果我在 app.tsx 中声明 useWorkspaceMessagesWorkspaceMessage 接口,错误就会消失。

找出问题所在。我的 .eslint.js

有误

我的 parserOptions.project 指向 tsconfig.json 的错误目录。可悲的是,eslint 并没有抱怨这个。