X
    Categories: Angularjs 2

Parameter implicitly has an ‘any’ type

Parameter implicitly has an ‘any’ type

Parameter implicitly has an ‘any’ type, I am working with angular 2 and typescript.  Have implemented my component and have try to run npm start at my termianl but It terminated with the following error : error TS7006: Parameter ‘response’ implicitly has an ‘any’ type

Error Message :

> angular-quickstart@1.0.0 start /Applications/MAMP/htdocs/*********
> tsc && concurrently "tsc -w" "lite-server" 

app/signup/sign-up-to-ride.component.ts(60,24): error TS7006: Parameter 'response' implicitly has an 'any' type.

npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "tsc -w" "lite-server" 
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Applications/MAMP/htdocs/*****/npm-debug.log

In my application Am trying to integrate Facebook login.


This is my Component :

export class FBLoginComponent  {

	public token: any;
	public logged: boolean = false;
	public user = { name : 'Hello' };
	public formActive:boolean = true;
	public submitted:boolean = false;

	onSubmit() {
    		this.submitted = true;
  	}
	constructor () {
		FB.init({
		        appId      : '*********',
		        cookie     : false, 
		        xfbml      : true,  // parse social plugins on this page
		        version    : 'v2.5' // use graph api version 2.5
	    	});
	}

	statusChangeCallback(response) {
	   ......
	}

	fbLogin() {
	    FB.login((result) => {
		    .......
               }
	}

	me() {
	    FB.api('/me?fields=id,name,first_name,gender,picture.width(150).height(150),age_range,friends',
	        function(result) {
	          .......
	        });
	}

	ngOnInit() {
	    FB.getLoginStatus(response => {
	        .......
	    });
	}
}

How to fix Parameter …… implicitly has an ‘any’ type

This is not an error, this is waring, you can disable this globally also.

Step 1 :

Declare variable with type for eg :

public token: any;
public logged: boolean = false;
etc…

Give type to function parameters :

statusChangeCallback(response : any) {
……
}

fbLogin() {
FB.login((result: any) => {
………
}

Step 2 : Disable Globally

Goto tsconfig.json
modify "noImplicitAny" to false

Example : 

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true
  }
}

 

Thanks for reading this article.
Hope it will help someone.

Marimuthu:

View Comments