[英]VSCode Eslint Error no-unsafe-assignment Incorrectly Displayed
[英]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 似乎無法獲取導入函數的返回類型。
在使用WorkspaceMessages.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 中聲明useWorkspaceMessages
和WorkspaceMessage
接口,錯誤就會消失。
弄清楚出了什么問題。 我的.eslint.js
有錯誤
我parserOptions.project
指着TE錯誤的目錄tsconfig.json
。 可悲的是,eslint 並沒有抱怨這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.