Typescript prompts implicitly has an 'any' type, how to solve this?

as mentioned in the title, during the compilation of typescript, the parameter of the function is prompted {variable name} implicitly has an "any" type, but I don"t know what type of parameter should be specified. I know that this verification rule can be turned off. Is there any other solution? PS, this is react,. I use the arrow function.


add "noImplicitAny" to tsconfig.json: false,


there are three cases of "I don't know":

  • I don't know exactly what it is, but it must have a so-and-so attribute: declare the type literally, {x: string}
  • I'm not sure what attributes it has, and then I'll use if to make a careful judgment: declare it as unknown type
  • .
  • I know it myself, so forget it: declare it as any type
Menu