HomeJava

TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type Angular Ionic

Like Tweet Pin it Share Share Email

In this article we are going to fix a common angular error – TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type. While working on an Angular or Ionic application also you can get this kind of error.

TS7006: Parameter 'xxx' implicitly has an 'any' type

Reason for TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type error :

After Angular version 12, the stricter type checking comes as a default setting. Prior to this at the time of creating a new angular project, developers had choices to choose either stricter type checking or not.

Challenges due to Parameter ‘xxx’ implicitly has an ‘any’ type ts(7006) error :

Due to this issue we can not build our application. Hence one can not run and deploy the application.

So since Angular 12, you might receive this error. In case you have not handled the typecasting properly, you might face this issue. 

In the long run this setting helps to maintain your project. But sometimes we need to disable it to run our application properly.

Fix for TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type error :

I also encountered this error. After surfing Google I found that it was because of the “strict” and “noImplicitAny” parameter. 

In the tsconfig.json file “strict” and “noImplicitAny” parameters were set to true. To fix this issue just set these parameters to false in tsconfig file.

Now your tsconfig.json file will look like this. Your file may not be exactly like this. So You need not to copy and paste the entire file blindly. As it may cause other issues.

So you can just change the values of noImplicitAny and strict inside compilerOptions. It should solve your problem.

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": false,
    "noImplicitOverride": true,
    "noImplicitAny": false,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": ["es2018", "dom"],
    "useDefineForClassFields": false
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Conclusion :

Hope you followed this solution. Finally, you should be able to fix compilation issue. In case you have further issues related to this, please message us in the comment box.

Reference :

You can also refer to stackoverflow for more information

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *