Home/TypeScript Errors/TS7031
Binding element 'X' implicitly has an 'any' type
TypeScript TS7031 fires when you destructure an object or array parameter and the destructured element has no type that TypeScript can infer, defaulting to an implicit 'any'. It's the destructuring equivalent of TS7006.
Why This Happens
You're destructuring a function parameter that isn't typed, or the outer object type doesn't specify the shape of the destructured properties. With noImplicitAny enabled, TypeScript requires all binding elements to have explicit types.
Code That Triggers TS7031
// TS7031 examples
// Untyped destructured parameter
function greet({ name, age }) {
// Error: Binding element 'name' implicitly has an 'any' type
// Error: Binding element 'age' implicitly has an 'any' type
return `Hello ${name}, age ${age}`;
}
// Array destructuring
function first([a, b]) {
// Error: Binding element 'a' implicitly has an 'any' type
return a;
}How to Fix TS7031
Option 1: Add a type annotation to the parameter
interface User { name: string; age: number }
function greet({ name, age }: User): string {
return `Hello ${name}, age ${age}`;
}Option 2: Inline the type annotation
function greet({ name, age }: { name: string; age: number }): string {
return `Hello ${name}, age ${age}`;
}Option 3: Type array destructuring
function first([a, b]: [number, number]): number {
return a;
}Frequently Asked Questions — TS7031
What does TS7031 mean?
TS7031 means you're destructuring a function parameter without a type annotation, so the destructured elements implicitly have type 'any'. Add a type to the parameter to fix it.
How is TS7031 different from TS7006?
TS7006 is for simple parameters (x), TS7031 is for destructured parameters ({ name, age }). Both fire when noImplicitAny is enabled and the type can't be inferred.
Should I use an interface or inline type for TS7031?
Use an interface when the shape is reused in multiple places. Use an inline type for one-off parameter shapes. Both fix TS7031 — it's a style choice.
TS7031 in event handlers — how to fix?
Type the event parameter: function handler({ target }: React.ChangeEvent<HTMLInputElement>). React provides event types for all DOM events in the @types/react package.
Can I use 'any' explicitly to suppress TS7031?
Yes — { name }: any suppresses it, but removes all type safety for the destructured props. Better to type the actual shape.
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 →
May 13, 2026
Convert XML to JSON Online: Complete Guide for Developers (2026)

May 11, 2026
Convert CSV to JSON Online Free (Best Developer Guide 2026)

May 6, 2026
Convert YAML to JSON Online Free (2026 Developer Guide)

Apr 30, 2026
Convert JSON to Zod Schema Online (2026) – Free Tool & Complete Guide

Apr 30, 2026
Top 50 JavaScript to TypeScript Converters (2026) – Free, AI & Online Tools