Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable 'a' implicitly has an 'any[]' type

I try to run npm start for my angular2 project

but get this error:

  push_quick git:(master) npm start

> [email protected] start /Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/push_quick
> tsc && concurrently "tsc -w" "lite-server"

app/shared/stringUtils.service.ts(8,9): error TS7005: Variable 'a' implicitly has an 'any[]' type.

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR!

for this method:

@Injectable()
export class StringUtilsService {

  mapToFormParamsString( dict : any) : string{
    var a:any[] = []
    for (var key in dict) {
      if (dict.hasOwnProperty(key)) {
        a.push(key+"="+dict[key]);
      }
    }
    return a.join("&");
  }
}

how can i fix this?

changing var a = string[] or var a = any[]

didn't help. same compilation error.

btw, I didn't have thi error when compiling with ng start or in intellij

Is ng start calling mpn start or visa versa ?

like image 877
Elad Benda2 Avatar asked Aug 30 '16 22:08

Elad Benda2


1 Answers

Probably, in the strinUtils.service.ts. A member or a variable of the componenet has not explicit type. A quick way to fix, since you are not providing the service code, may be

var a:string[] = [] 

The error showed happens on the linting validations, sometimes if the linter is no passing it breaks the compile runtime.

like image 55
afmeva Avatar answered Sep 28 '22 12:09

afmeva