When using MapView.goTo, it always gives Typescript error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((target: Geometry | Graphic | Graphic[] | Viewpoint | number[] | Geometry[] | MapViewGoToTarget,...' has no compatible call signatures.
The goto function working fine, just this tslint error breaks the build.
Does anyone have similar issues? below is my code:
The typing file is:
goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | MapViewGoToTarget, options?: MapViewGoToOptions): IPromise<ViewAnimation>;
Just don't understand why tslint give this error, can someone shed some lights?
Thanks!
Solved! Go to Solution.
It could be a version thing. I am using Visual Studio Code and the version I'm using has TypeScript 2.6.1. and TSLint from here: GitHub - Microsoft/vscode-tslint: A tslint integration for vscode
I've attached my test app.
After spent some time on google, seems it's because view.goto() uses union types which typescript doesn't like, one solution is to change source code to use method overload, which is not an option for me. Are there any other ways to resolve it?
I just ran a quick test using the latest version of the API (4.6) and the typings from here and when I didn't get any errors when transpiling. Here's the code I used.
Thanks Kelly, I downloaded the new type file and still get same error, could it because npm packages I used are different? here're what I used:
Could you upload your sample project?
Thanks!
It could be a version thing. I am using Visual Studio Code and the version I'm using has TypeScript 2.6.1. and TSLint from here: GitHub - Microsoft/vscode-tslint: A tslint integration for vscode
I've attached my test app.
Thanks Kelly, after compared your project with mine, I found the cause is that my view is declared as union type:
even if these two views has same goTo functions, typescript still doesn't like it, after manually cast my view to specific type, the error is gone, the error message is kind of misleading.
Thanks again for your help. much appreciated!