这是indexloc提供的服务,不要输入任何密码
Skip to content

ESLint Error: Unsafe assignment of an 'any' value. #65

@BenJackGill

Description

@BenJackGill

I'm using vue-concurrency with TypeScript and ESLint.

I am aware of the TypeScript limitations and that intermediate values need to be explicily typed or else they will be given a type of any.

But after typing my intermediate values ESLint still complains about the any value: Unsafe assignment of an 'any' value. eslint(@typescript-eslint/no-unsafe-assignment)

Here is my full code, with comment on the error line:

import { db } from 'src/firebase/config';
import { doc, getDoc, DocumentSnapshot } from 'firebase/firestore';
import { useTask } from 'vue-concurrency';

const getDocumentTask = useTask(function* (
  signal,
  collectionName: string,
  documentId: string
) {
  const documentReference = doc(db, collectionName, documentId);
  const response: DocumentSnapshot = yield getDoc(documentReference); // <-- EsLint error here
  const document: Record<string, unknown> = {
    ...response.data(),
    documentId: response.id,
  };
  return document;
});

export default getDocumentTask;

Is this a bug or am I doing something wrong?

I could disable the ESLint error with // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment but I would rather solve the problem instead of disabling it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions