Special Sponsor:PromptBuilder— Fast, consistent prompt creation powered by 1,000+ expert templates.
Make your Product visible here.Contact Us

Home/TypeScript Errors/TS2461

TS2461

Type 'X' is not an array type

TypeScript TS2461 fires when you use array destructuring or spread syntax on a value that isn't typed as an array or iterable. TypeScript requires the value to have an array type or implement the iterable protocol.

Why This Happens

You're trying to destructure ([a, b] = value) or spread (...value) a value whose type isn't an array, tuple, or iterable. Common with objects, strings in non-iterable contexts, or values typed as unknown/any that resolve to non-arrays.

Code That Triggers TS2461

// TS2461 examples

// Destructuring a non-array
const obj = { x: 1, y: 2 };
const [a, b] = obj;
// Error: Type '{ x: number; y: number }' is not an array type

// Spreading in array context
function combine(...args: number[]): number[] {
  const source = { data: [1, 2, 3] };
  return [...source]; // Error: Type '{ data: number[] }' is not an array type
  // Should be: return [...source.data]
}

How to Fix TS2461

Option 1: Destructure the correct property

const source = { data: [1, 2, 3] };
const [a, b] = source.data; // access .data first

Option 2: Convert to array before destructuring

const obj = { x: 1, y: 2 };
const entries = Object.values(obj); // [1, 2]
const [a, b] = entries; // OK

Option 3: Use object destructuring instead of array destructuring

const obj = { x: 1, y: 2 };
const { x, y } = obj; // correct for objects

Frequently Asked Questions — TS2461

What does TS2461 mean?

TS2461 means you're trying to use array destructuring or spread on a value that isn't an array or iterable. Check if you're accessing the right property — you may be destructuring an object that contains an array instead of the array itself.

TS2461 with Object.entries — how to fix?

Object.entries returns [string, T][], which is iterable. If you're getting TS2461, check that you're calling Object.entries() (with parentheses) and not accessing it as a property.

Can I make an object iterable to fix TS2461?

Yes — implement the Symbol.iterator method on the object to make it iterable. TypeScript will then allow destructuring and spread. This is advanced and usually not the right fix — accessing the array property directly is simpler.

TS2461 with Map or Set — how to fix?

Map and Set are iterable but not arrays. You can spread them into arrays: [...myMap.entries()] or [...mySet]. For array destructuring, convert first: Array.from(mySet).

TS2461 vs TS2488 — what's the difference?

TS2461 is 'not an array type', TS2488 is 'must have [Symbol.iterator] method'. TS2461 fires on array destructuring/spread, TS2488 fires in for...of loops. Both indicate a non-iterable value.

Convert JavaScript to TypeScript automatically

Paste your JS code and get type-annotated TypeScript — including fixes for common type errors — in seconds.

Try the converter →

Other TypeScript Errors

From the blog

View all →