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.
Figured out what was wrong. I had a mistake in my .eslint.js
my parserOptions.project
was pointing to te wrong directory for tsconfig.json
. Sadly, eslint does not complain about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With