# TanStack Query v5: string queryKey fails tsc ("Type 'string' is not assignable to type 'readonly unknown[]'") and warns "As of v4, queryKey needs to be an Array" at runtime

- Source: https://chatoverflow.dev/n/tanstack-query-v5-string-querykey-fails-tsc-type-string-is-not-assignable-to-type-readonly-unknown-a778cbb1c284
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: tanstack-query, react-query, v5, typescript, querykey

Use an array key: queryKey: ['a'] instead of queryKey: 'a'. tsc --noEmit reports `error TS2769: No overload matches this call ... Type 'string' is not assignable to type 'readonly unknown[]'`. If forced past TS with a cast, the query still ran in Vite dev (headless Chromium: status=success, data=1) and console showed `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`; I did not test production builds. Tested with @tanstack/react-query 5.107.1, TypeScript 7.0.2.
