TS7006
TypeScript Programming Language
Severity: MinorWhat Does This Error Mean?
TypeScript error TS7006 means a function parameter has no type annotation, and TypeScript cannot infer what type it should be. In strict mode, TypeScript refuses to silently assume a parameter is 'any' — it requires an explicit type. This error only appears when noImplicitAny is enabled in tsconfig.json, which is included in strict mode. Fix it by adding a type annotation to the parameter: (name: string) instead of just (name).
Affected Models
- TypeScript 2.0 and later
- All TypeScript versions with noImplicitAny or strict mode
- tsc compiler, ts-node, webpack, Vite, Next.js
Common Causes
- Writing a function parameter without a type annotation: function greet(name) instead of function greet(name: string)
- Using noImplicitAny: true or strict: true in tsconfig.json, which enables this check
- Arrow function parameters without annotations: const fn = (x) => x * 2 instead of (x: number) => x * 2
- Callback parameters in array methods like .map() or .forEach() without type annotations
- Migrating a JavaScript project to TypeScript where types were never written
How to Fix It
-
Find the function with the unannotated parameter. Add a type annotation after the parameter name with a colon: (name: string).
Common types: string, number, boolean, string[], number[], object, or a custom interface you define.
-
For arrow functions in array methods, add the type to the callback parameter: myArray.map((item: string) => item.toUpperCase())
TypeScript can often infer the type from the array type automatically. If myArray is string[], the callback gets (item: string) inferred.
-
If you genuinely do not know the type yet, use unknown instead of any: (value: unknown). Then narrow the type before using it.
unknown is safer than any. It forces you to check the type before using the value, unlike any which skips all checks.
-
If you are migrating a JavaScript project and cannot add types right now, temporarily set noImplicitAny: false in tsconfig.json.
This suppresses TS7006 across the whole project. Re-enable it once you have added type annotations throughout.
-
For event handler callbacks, TypeScript often provides the correct type automatically. Use your IDE's quick fix suggestion to insert the correct annotation.
In VS Code, press Ctrl+. on the red-underlined parameter to see suggested type annotations.
When to Call a Professional
TS7006 is a compile-time error. It only appears in projects with strict type checking enabled. It is easy to fix: add a type annotation to the parameter. If you are migrating a large JavaScript project, you can temporarily set noImplicitAny to false while you add types gradually.
Frequently Asked Questions
What is 'any' in TypeScript and why is implicit any bad?
The any type tells TypeScript to stop checking a value entirely. It is like turning off TypeScript for that variable. Implicit any means TypeScript assigned 'any' silently without you asking for it. This usually means a type annotation was forgotten. TypeScript warns you so you do not accidentally disable type checking.
Should I use 'any' to fix TS7006 quickly?
You can write (param: any) to silence the error, but it is not a real fix. any disables type checking for that value, removing the benefit of TypeScript. Use the correct type whenever possible. If you truly do not know the type, unknown is the safer alternative.
What is the difference between noImplicitAny and strict mode?
noImplicitAny is a single TypeScript option that enables the TS7006 check. strict mode is a group of several strict checks bundled together, and it includes noImplicitAny. If you set strict: true in tsconfig.json, noImplicitAny is automatically enabled along with several other strict checks.