How to fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript?

Sometimes, we want to fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript.

In this article, we’ll look at how to fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript.

How to fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript?

To fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript, we should specify the parameter’s data type if we have the noImplicitAny flag on.

For instance, we write

const user = users.find((user: any) => user.id === query);

to set the user parameter’s type to any to suppress the error.

Conclusion

To fix the “Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type” error with TypeScript, we should specify the parameter’s data type if we have the noImplicitAny flag on.