I'm getting no-unsafe-call and also no-unsafe-assignment eslint errors when importing a typed function. If the function is declared in the same file, the error goes away. It seems that eslint is not able to get the return type of the imported function.
In useWorkspaceMessages.ts
export interface WorkspaceMessage {
message: string;
created: string;
}
export default function useWorkspaceMessages(): WorkspaceMessage[] {
return [];
}
In 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
If I declare useWorkspaceMessages and the WorkspaceMessage interface in app.tsx the error goes away.