Skip to content

[eslint-plugin-query] no-void-query-fn false positive on enum returns with TypeScript 6 #10461

Closed

Description

@park-jemin

Describe the bug

The no-void-query-fn rule incorrectly reports queryFn must return a non-undefined value when a queryFn returns a TypeScript enum member. This only occurs when using TypeScript 6.0.

On investigating, looks like we're implicitly relying on these values for TypeFlags which should be internal to TS.

const TypeFlags = {
  Void: 16384,
  Undefined: 32768,
} as const

function isIllegalReturn(checker: TypeChecker, type: Type): boolean {
  const awaited = checker.getAwaitedType(type)

  if (!awaited) return false

  if (awaited.isUnion()) {
    return awaited.types.some((t) => isIllegalReturn(checker, t))
  }

  return awaited.flags & (TypeFlags.Void | TypeFlags.Undefined) ? true : false
}

The underlying values for TypeFlags were reorderd in this change: microsoft/TypeScript#63084. This ends up actually testing for UniqueESSymbol | EnumLiteral instead of Void | Undefined as intended.

Steps to reproduce

On TypeScript 6, the below triggers the lint violation:

import { useQuery } from '@tanstack/react-query'

enum ExampleEnum {
  A,
}

export function useExampleEnum() {
  return useQuery({
    queryKey: ['exampleEnum'],
    queryFn: () => {
      return ExampleEnum.A
    },
  })
}

Expected behavior

Returning an enum value from queryFn should not trigger no-void-query-fn.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

all

Tanstack Query adapter

None

TanStack Query version

v5.99.0

TypeScript version

v6.0.2

Additional context

Quick fix addressing this: #10460

Activity

  1. added a commit that references this issue on Apr 13, 2026
    405410f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions