Ela*_*da2 7 typescript angular
我尝试npm start
为我的 angular2 项目运行
但得到这个错误:
push_quick git:(master) npm start
> angular2-quickstart@1.0.0 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! angular2-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR!
Run Code Online (Sandbox Code Playgroud)
对于这种方法:
@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("&");
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
改变var a = string[]
或var a = any[]
没有帮助。同样的编译错误。
顺便说一句,我在编译ng start
或在 intellij 中没有这个错误
是ng start
打电话mpn start
还是反之?
afm*_*eva 16
可能,在 strinUtils.service.ts 中。组件网的成员或变量没有明确的类型。由于您没有提供服务代码,因此一种快速修复方法可能是
var a:string[] = []
Run Code Online (Sandbox Code Playgroud)
显示的错误发生在 linting 验证中,有时如果 linter 没有通过它会破坏编译运行时。