Typescript: TS7006: Parameter 'xxx' implicitly has an 'any' type
You are using the --noImplicitAny
and TypeScript doesn't know about the type of the Users
object. In this case, you need to explicitly define the user
type.
Change this line:
let user = Users.find(user => user.id === query);
to this:
let user = Users.find((user: any) => user.id === query);
// use "any" or some other interface to type this argument
Or define the type of your Users
object:
//...
interface User {
id: number;
name: string;
aliases: string[];
occupation: string;
gender: string;
height: {ft: number; in: number;}
hair: string;
eyes: string;
powers: string[]
}
//...
const Users = <User[]>require('../data');
//...
In your tsconfig.json
file set the parameter "noImplicitAny": false
under compilerOptions
to get rid of this error.
if you get an error as Parameter 'element' implicitly has an 'any' type.Vetur(7006) in vueJs
with the error:
exportColumns.forEach(element=> {
if (element.command !== undefined) {
let d = element.command.findIndex(x => x.name === "destroy");
you can fixed it by defining thoes variables as any as follow.
corrected code:
exportColumns.forEach((element: any) => {
if (element.command !== undefined) {
let d = element.command.findIndex((x: any) => x.name === "destroy");